Elasticsearch Query String with shingle filter not working

370 views Asked by At

I have problem with shingle filter.

My setting shingle below:

    "filter_shingle": {
      "type": "shingle",
      "min_shingle_size": 2,
      "max_shingle_size": 3,
      "output_unigrams": false
    }

    "analyzer_1": {
      "type": "custom",
      "tokenizer": "standard",
      "filter": ["asciifolding","lowercase","filter_shingle"]
    }

i expect field data example: "My name is", after procee with this filter, data become:

  "my name"
  "my name is"
  "name is"

...

"field1" using "analyzer_1"

Query string here (don't using "match_phrase")

  "query_string" : {
    "default_operator": "AND",
      "fields" : ["field1"],
      "query" : "My name",
      "analyzer": "keyword"
  }

But no data retrieve, not thing erros throw when I create index with mapping and analyzer.

Can anyone help me, thank you so much (sorry for poor EN)

1

There are 1 answers

0
Val On

Since you're using a keyword analyzer in your query_string query, you need to type your input in lowercase, i.e. my name instead of My name, since your indexed token is my name and not My name

  "query_string" : {
    "default_operator": "AND",
      "fields" : ["field1"],
      "query" : "my name",        <-- change this
      "analyzer": "keyword"
  }