1

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"]
    }

}

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.