0

I am trying to implement "did you mean" feature using the elasticsearch phrase suggester. It works OK, except when using field search in query syntax.

The query syntax I use is Query String Query

Here is an example of a query:

{
  "from" : 0,
  "size" : 10,
  "query" : {
    "query_string" : {
      "query" : "defect.fields.description:(tetsing)",
      "use_dis_max" : true
    }
  },
  "suggest" : {
    "phrase-suggest-iris" : {
      "text" : "defect.fields.description:(tetsing)",
      "phrase" : {
        "analyzer" : "default",
        "field" : "_all",
        "max_errors" : 2.0,
        "highlight" : {
          "pre_tag" : "<b>",
          "post_tag" : "</b>"
        }
      }
    }
  }
}

And here is what I get in the suggestions:

defect.fields.description testing

The ":" is missing from the suggestions and other operators like "()". It seems like the suggeter does not keep query syntax.

Any help/suggestion would be appreciated.

Thanks!

Lital Kolog
  • 1,301
  • 14
  • 39
  • Why not simply having this in your suggester `"text" : "tetsing"` ? The suggesters do not support the Lucene query string language, simply text tokens that you want to get suggestions on. – Val May 02 '16 at 06:38
  • That would require me to parse the query myself, I wanted to avoid that... – Lital Kolog May 02 '16 at 06:43
  • So that means your users are providing the content of the query string and you're using that raw input directly in your query? – Val May 02 '16 at 06:44
  • Yes, it can be anything and combine free text with field search, e.g. `"test framework defect.fields.description:login"` – Lital Kolog May 02 '16 at 06:47

0 Answers0