0

I send this query and it works fine. It returns filtered data:

{
    "query": {
        "bool": {
            "filter": [
                {
                    "match": {
                        "lang": "en"
                    }
                }
            ]
        }
    },
    "size": 10,
    "from": 0,
    "sort": []
}

If I want to search with searchstring then it workst fine too:

{
    "query": {
        "query_string": {
            "query": "big size"
        }
    },
    "size": 10,
    "from": 0,
    "sort": []
}

But I can't get data from elastic by filter and searchstring together:

{
    "query": {
        "query_string": {
            "query": "big size"
        },
        "bool": {
            "filter": [
                {
                    "match": {
                        "lang": "en"
                    }
                }
            ]
        }
    },
    "size": 10,
    "from": 0,
    "sort": []
}

I receive next error:

Error 400.
{"error":{"root_cause":[{"type":"parsing_exception","reason":"[query_string] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":76}],"type":"parsing_exception","reason":"[query_string] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":76},"status":400}

1 Answer 1

1

Your query needs to be restructured as shown below.

Query:

{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "big size"
          }
        }
      ],
      "filter": [
        {
          "match": {
            "lang": "en"
          }
        }
      ]
    }
  },
  "size": 10,
  "from": 0,
  "sort": []
}
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.