nGram Autocomplete


(Hrachya Yeghishyan) #1

I have implemented multifield partial autocomplete using nGram-s as presented in the following blogpost: https://qbox.io/blog/multi-field-partial-word-autocomplete-in-elasticsearch-using-ngrams
It works great in case of a single match query. However, it fails when using the same match query inside a boolean query which contains several other queries as well.
Is there any way to gain the same result as a single match query provides in case of a boolean query?

For instance the match query below works as expected. It retrieves all those documents which contain both "shop" and "mi".

{
     "query": {
         "match" : {
            "_all": {
                 "query": "shop mi",
                 "operator": "and"
            }
         }
     }
 }

Whereas the boolean query below, which contains the same match query doesn't retrieve any documents. It results in 0 hits. However, it should also retrieve all those documents, which contain both "shop" and "mi", but having values for the "@timestamp" field in the specified range.

{
"query": {
  "bool" : {
    "must" : [
      {
        "range" : {
          "@timestamp" : {
            "from" : 1516881600000,
            "to" : 1516882500000,
            "include_lower" : true,
            "include_upper" : true,
            "format" : "epoch_millis",
            "boost" : 1.0
          }
        }
      }
    ],
    "filter" : [
      {
        "match" : {
          "_all" : {
            "query" : "shop mi",
            "operator" : "and",
            "boost" : 1.0
          }
        }
      }
    ],
    "boost" : 1.0
  }
 }
}

(Hrachya Yeghishyan) #2

Resolved: Actually there is no problem with the second query. It came out that there was no document that contained "shop mi" and had a value of "@timestamp" in the specified range. When changing the parameters of the range query properly, the boolean query does return a document containing "shop mi".


(system) #3

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