# Search result not expected

**URL:** <https://discuss.elastic.co/t/search-result-not-expected/23194>\
**Category:** Elasticsearch\
**Created:** [April 10, 2015, 9:00pm UTC](https://discuss.elastic.co/t/search-result-not-expected/23194 "2015-04-10T21:00:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chen\_Wang](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@Chen\_Wang](https://discuss.elastic.co/u/Chen_Wang)\
**Post date:** [April 10, 2015, 9:00pm UTC](https://discuss.elastic.co/t/search-result-not-expected/23194/1 "2015-04-10T21:00:11Z")

</div>

Hello folks,  
I have a nested query:

"query":  
{"filtered":{"query":{"match\_all":{}},"filter":{"nested":{"path":"browse","filter":{"bool":{"must":[{"term":{"browse.subcat.raw":["desktop  
tower"]}}]}}}}}}

as you can see, browse is a nested object. subcat.raw is using keyword  
tokenizer.  
the above query can return a customer with customerId1,

"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "user\_activity",  
"\_type": "2015-02-15",  
"\_id": "customerid1",  
"\_score": 1,  
"\_source": {  
"browse": [  
{  
"item\_id": "item1",  
"subcat": "DESKTOP TOWER"  
"event\_time": "2015-02-15"  
}  
]  
}  
}  
]

similarly if I do another query  
"query":  
{"filtered":{"query":{"match\_all":{}},"filter":{"nested":{"path":"browse","filter":{"bool":{"must":[{"term":{"browse.subcat.raw":["knit  
tops"]}}]}}}}}}  
It will return another customer customerId2  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "user\_activity\_v2",  
"\_type": "2015-02-15",  
"\_id": "customerId2",  
"\_score": 1,  
"\_source": {  
"browse": [  
{  
"item\_id": "item3",  
"subcat": "KNIT TOPS",  
"event\_time": "2015-02-15"  
},  
{  
"item\_id": "item4",  
"subcat": "ACTIVEWEAR",  
"event\_time": "2015-02-15"  
},  
{  
"item\_id": "item5",  
"subcat": "ACTIVEWEAR",  
"event\_time": "2015-02-15"  
}  
]  
}  
}  
]  
}

But if i combined these two queries together:  
"query":  
{"filtered":{"query":{"match\_all":{}},"filter":{"nested":{"path":"browse","filter":{"bool":{"must":[{"term":{"browse.subcat.raw":["knit  
tops","desktop tower"]}}]}}}}}}  
It only returns customerId1. which corresponds to "desktop tower". It seems  
that the combined query always return the matched customer\_id for the last  
search term in the browse.subcat.raw.

Is this expected? or i am doing something wrong? I am hoping the combined  
query would return both customerId1, and customerId2  
Chen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a88cd340-76ef-4a6b-a647-baa253b23fb1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a88cd340-76ef-4a6b-a647-baa253b23fb1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:20am UTC](https://discuss.elastic.co/t/search-result-not-expected/23194/2 "2017-07-06T00:20:17Z")

</div>

Closed on July 6, 2017, 12:20am UTC


