Reputation: 349
I know this works:
{
"query": {
"query_string": {
"query": "reading,debating"
}
}
It searchs for all occurances of the words reading or debating. I want to know if there is a way so that I instead of having a comma separated string we can insert an array of strings? To sort of look like this:
{
"query": {
"query_string": {
"query": ["reading","debating"]
}
}
Upvotes: 1
Views: 1096
Reputation: 1415
In your first example it is a QueryString query where elasticsearch internally handled the query understanding, and by default comma is a delimiter which is how your first query worked.
In this case probably what do you want is two or multiple term queries combined by a boolean(use "should" if you want OR logic and "must" if you want AND logic) query.
Here is how you can do it from curl: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
If you want to use it programmatically in Java, you can use the QueryBuilders to construct a term queries and boolean query
Upvotes: 5