1

I have just started using Elastic search and am stuck with the following use case -

I am using complete suggester in elastic search with auto fuzziness setting to get city suggestions as output. My city name in completion field has weights according to popularity. The problem is the ordering in case of fuzzy results.

Example if user types "dilh" -> I would want to give "delhi" result above "digha" or "dighwara" owing to popularity i.e. weights assigned to different cities. Right now "digha","dighwara","Dihira" etc are coming above more relevant cities like "delhi" or "dalhousie". Since the edit distance is same anyone can let me know how can I configure this so the order is according to the weights of cities?

Attaching sample request:

        {
          "suggest": {
            "loc-suggest2": {
              "prefix": "dilh",        
              "completion": { 
                  "field": "suggestedNames",
                  "size":20,
                  "fuzzy": {
                  "fuzziness": auto
                }
              }
            }
          }
        }   

1
  • Can you please specify how your completion field has weights? In general using weights can't be used with Suggest API of Elasticsearch, although it's possible with Lucene. You could classify the cities into different categories (e.g. XXL, XL, L... or "metropolis", "city", "town") and use context suggest API to boost the matches according to these classifications.
    – rudi
    Jun 9, 2021 at 23:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.