# Match a indexed field with array of strings

**URL:** <https://discuss.elastic.co/t/match-a-indexed-field-with-array-of-strings/129597>\
**Category:** Elasticsearch\
**Created:** [April 26, 2018, 6:42am UTC](https://discuss.elastic.co/t/match-a-indexed-field-with-array-of-strings/129597 "2018-04-26T06:42:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moumita\_Mandal](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@Moumita\_Mandal](https://discuss.elastic.co/u/Moumita_Mandal)\
**Post date:** [April 26, 2018, 6:42am UTC](https://discuss.elastic.co/t/match-a-indexed-field-with-array-of-strings/129597/1 "2018-04-26T06:42:36Z")

</div>

Hello,

Currently, I am using Elasticsearch version 5.3.2.  
I have multiple documents in the below format:  
{  
"id":"abc123"  
"question":"What is 1004 divided by 2?",  
"answer":" A. 52, B. 502, C. 520,D. 5002",  
"category": "math"  
}  
{  
"id":"asd456"  
"question":"Which is the nearest star to planet earth? ",  
"answer":"sun",  
"category": "general knowledge"  
}  
{  
"id":"nmb897"  
"question":"Which is the heavier metal of these two? Gold or Silver? ",  
"answer":"gold",  
"category": "science"  
}

I want to fetch documents with a category that falls under an array ["math","science"].

I have tried using terms query. But that didn't work.  
My query was like :  
{  
"query": {  
"bool": {  
"should": {  
"terms": { "category": ["math","science"]}  
}  
}  
}  
};

Help me with this.

---

<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:** [May 24, 2018, 6:42am UTC](https://discuss.elastic.co/t/match-a-indexed-field-with-array-of-strings/129597/2 "2018-05-24T06:42:51Z")

</div>

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