# High Rest Client | Search for any value from list

**URL:** <https://discuss.elastic.co/t/high-rest-client-search-for-any-value-from-list/235062>\
**Category:** Elasticsearch\
**Created:** [May 31, 2020, 11:18am UTC](https://discuss.elastic.co/t/high-rest-client-search-for-any-value-from-list/235062 "2020-05-31T11:18:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AsfK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asfk/32/58995_2.png) [@AsfK](https://discuss.elastic.co/u/AsfK)\
**Post date:** [May 31, 2020, 11:18am UTC](https://discuss.elastic.co/t/high-rest-client-search-for-any-value-from-list/235062/1 "2020-05-31T11:18:28Z")

</div>

I have a simple index contains filename and status and I want to get all documents contains any filename from a given list.

Below is a document sample:

```
{
    "_index" : "filestracking",
    "_type" : "_doc",
    "_id" : "File_2020_05_22_001.csv",
    "_score" : 1.0,
    "_source" : {
       "fileName" : "File_2020_05_22_001.csv",
       "status" : "EXPECTED"
    }
}

```

I wrote a simple query to receive all documents that their fileName match a value from a list:

```
SearchRequest searchRequest = new SearchRequest(trackingIndex);
QueryBuilder query = QueryBuilders.termsQuery("fileName", fileList);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(query);
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = getSearchResponseWithAttempts(searchRequest);
searchResponse.getHits().getHits();

```

but I find nothing (fileList is a List).

Can you help me please, how to find all documents match any value of a given list (fileList) ?

Thank you!

**EDIT**  
\_id and fileName contains same values. searching for \_id return results (fileName is of text type in the mapping).  
I don't know why \_id works but if you know I'll be glad to know too 🙂

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 31, 2020, 3:44pm UTC](https://discuss.elastic.co/t/high-rest-client-search-for-any-value-from-list/235062/2 "2020-05-31T15:44:31Z")

</div>

> [@AsfK](#):
>
> fileName is of text type in the mapping

Change it to `keyword` or use the `keyword` analyzer on this field.

If you are using the default mapping, you can may be run the query against `fileName.keyword`.

---

<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:** [June 28, 2020, 3:44pm UTC](https://discuss.elastic.co/t/high-rest-client-search-for-any-value-from-list/235062/3 "2020-06-28T15:44:34Z")

</div>

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