0

In the Elasticsearch documentation of the match_bool_prefix query, it is stated that the query

GET /_search
{
  "query": {
    "match_bool_prefix" : {
      "message" : "quick brown f"
    }
  }
}

is equivalent to

GET /_search
{
  "query": {
    "bool" : {
      "should": [
        { "term": { "message": "quick" }},
        { "term": { "message": "brown" }},
        { "prefix": { "message": "f"}}
      ]
    }
  }
}

I find very useful the possibility of having a query break the input into tokens automatically, but I have two questions:

  1. Assuming the field message is a regular text field, isn't it "wrong" to use term queries with it? Shouldn't they be match queries instead?
  2. What would be equivalent queries (similar to match_bool_prefix with message: "quick brown f") to the following three queries? Also, do all three make sense?

Query A:

GET /_search
{
  "query": {
    "bool" : {
      "should": [
        { "match": { "message": "quick" }},
        { "match": { "message": "brown" }},
        { "prefix": { "message": "f"}}
      ]
    }
  }
}

Query B:

GET /_search
{
  "query": {
    "bool" : {
      "should": [
        { "term": { "message": "quick" }},
        { "term": { "message": "brown" }},
        { "term": { "message": "f"}}
      ]
    }
  }
}

Query C:

GET /_search
{
  "query": {
    "bool" : {
      "should": [
        { "match": { "message": "quick" }},
        { "match": { "message": "brown" }},
        { "match": { "message": "f"}}
      ]
    }
  }
}

Thanks a lot in advance!

UPDATE: Is it possible that Query C is just a simple match query?

0 Answers0