0

this is my ES5 index settings :

dev: {
  settings: {
    index: {
      number_of_shards: "5",
      provided_name: "dev",
      creation_date: "1491735064046",
      analysis: {
        filter: {
          trigrams_filter: {
            type: "ngram",
            min_gram: "3",
            max_gram: "3"
            }
         },
        analyzer: {
          trigrams: {
            filter: [
              "lowercase",
              "trigrams_filter"
            ],
            type: "custom",
            tokenizer: "standard"
           }
         }
       },
     number_of_replicas: "1",
     uuid: "2dcgz81ET0GRFa-EEwsUhA",
     version: {
       created: "5020299"
     }
   }
 }

},

this query would give 1 result as expected:

{'from': 0,
 'query': {'bool': {'filter': [{'term': {'public': True}}],
                    'must': [{'multi_match': {'fields': ['author_name',
                                                         'title^5',
                                                         'title_ngram',
                                                         'title.ngram',
                                                         'title.stemmed',
                                                         'text^3',
                                                         'text.stemmed',
                                                         'keywords',
                                                         'keywords.stemmed',
                                                         'categories',
                                                                 'categories.stemmed'],
                                              'fuzziness': 'AUTO',
                                              'query': u'austrailia'}}]}},
 'size': 20}

because there is a article with title australia.

however this query for aust would not give any result:

{'from': 0,
 'query': {'bool': {'filter': [{'term': {'public': True}}],
                    'must': [{'multi_match': {'fields': ['author_name',
                                                         'title^5',
                                                         'title_ngram',
                                                         'title.ngram',
                                                         'title.stemmed',
                                                         'text^3',
                                                         'text.stemmed',
                                                         'keywords',
                                                         'keywords.stemmed',
                                                         'categories',
                                                             'categories.stemmed'],
                                              'fuzziness': 'AUTO',
                                              'query': u'austrailia'}}]}},
 'size': 20}

I've read through all the ES5 documentation but still can't get this to work.

Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89
uri.lazar
  • 329
  • 3
  • 10
  • Can you also provide the mapping for all those fields in your queries and some sample documents? – Andrei Stefan Apr 30 '17 at 08:12
  • You will not get something for `aust` because your ngrams are for only 3 letters: `"min_gram": "3", "max_gram": "3"` and `aust` is made of 4 letters. If you want `aust` or anything longer than that to match then use `max_gram: 10` or something bigger. – Andrei Stefan Apr 30 '17 at 08:17

1 Answers1

1

You will not get something for aust because your ngrams are for only 3 letters: "min_gram": "3", "max_gram": "3" and aust is made of 4 letters. If you want aust or anything longer than that to match then use max_gram: 10 or something bigger.

Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89