Match a indexed field with array of strings

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.

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