How to do a match_phrase query on all searchable fields instead of on a single field?

How to do a match_phrase query on all searchable fields instead of on a single field?
I do see in the documentation as mentioned below where search can be done on only specific field.

GET /_search
{
"query": {
"match_phrase": {
"message": "this is a test"
}
}
}
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html

Thanks,
M'Jay

"match" and "match_phrase" query work on a single field.
If you want to use multiple fields with a phrase, you need to use multi_match query with type: phrase:

{
  "query": {
    "multi_match": {
      "query": "this is a test",
      "fields": ["*"],
      "type" : "phrase"
    }
  }
}
1 Like

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