# Search query for either of the value matches

**URL:** <https://discuss.elastic.co/t/search-query-for-either-of-the-value-matches/155786>\
**Category:** Elasticsearch\
**Created:** [November 7, 2018, 8:07pm UTC](https://discuss.elastic.co/t/search-query-for-either-of-the-value-matches/155786 "2018-11-07T20:07:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiv94](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@shiv94](https://discuss.elastic.co/u/shiv94)\
**Post date:** [November 7, 2018, 8:07pm UTC](https://discuss.elastic.co/t/search-query-for-either-of-the-value-matches/155786/1 "2018-11-07T20:07:55Z")

</div>

Hey, search query doesn't return either of the values

GET /\_search  
{  
"query": {  
"bool": {  
"must": [  
{  
"term": {  
"source": "/var/log/elasticsearch/server1/xxx-1.log"  
}  
},  
{  
"term": {  
"source": "/var/log/elasticsearch/server2/xxx-1.log"  
}  
},  
{  
"term": {  
"source": "/var/log/elasticsearch/server3/xxx-1.log"  
}  
}  
]  
}  
}  
}

This works if the source field must match 3 values?? I want to get the indices that match any value of the 3 paths specified. Is there any other way?

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 8, 2018, 4:57am UTC](https://discuss.elastic.co/t/search-query-for-either-of-the-value-matches/155786/2 "2018-11-08T04:57:00Z")

</div>

Change `must` clause to `should`. It will return all documents that match at least one of these 3. Documents that match more clauses will get higher scores and hence ranks.

---

<div class="post-metadata">

**Author:** ![shiv94](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@shiv94](https://discuss.elastic.co/u/shiv94)\
**Post date:** [November 8, 2018, 1:32pm UTC](https://discuss.elastic.co/t/search-query-for-either-of-the-value-matches/155786/3 "2018-11-08T13:32:22Z")

</div>

Thanks!

---

<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:** [December 6, 2018, 1:32pm UTC](https://discuss.elastic.co/t/search-query-for-either-of-the-value-matches/155786/4 "2018-12-06T13:32:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
