0

I am trying to retrieve records that match two queries.

First one is match_phrase

"match_phrase": {
                    "searchstring": {
                    "query": "' . $searchQ . '",
                    "slop":  10
                    }
                }

Second one I am using multi match

"multi_match": {
                    "query":    "' . $searchQ . '",
                    "fields" : ["_all"],
                    "type":       "cross_fields",
                }

how can I do this correctly. Please help

1 Answer 1

2

You can use a bool/must (or bool/should) query in order to combine your two queries:

{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "searchstring": {
              "query": "xyz",
              "slop": 10
            }
          }
        },
        {
          "multi_match": {
            "query": "xyz",
            "fields": [
              "_all"
            ],
            "type": "cross_fields"
          }
        }
      ]
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Val , Many thanks for the tip in the right direction

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.