Increase input fields to complete

I use the final examiner to autocomplete. These are my documents.

/* doc 1 */ { Title: CineMAX: Inorbit Mall, Cyberabad Suggest: { input: [ CineMAX: Inorbit Mall Cyberabad CineMAX: Inorbit Mall, Cyberabad ] output: CineMAX: Inorbit Mall, Cyberabad payload: { .... } weight: 1 } } /* doc 2 */ { Title: INOX: Kolkata Suggest: { input: [ INOX: Kolkata INOX: Kolkata ] output: INOX: Kolkata payload: { .... } weight: 1 } } 

Im using a completion request as shown below

 { "suggestion":{ "text":"inox", "completion":{ "field":"Suggest", "fuzzy":{ "edit_distance":1, "transpositions":true, "prefix_length":1, "min_length":4 } } } } 

But here I get the output as

  • CineMAX: Inorbit Mall, Cyberabad,
  • INOX: Calcutta

I want to pay more attention to exact match. So I want INOX: Kolkata strong> at the top.

I split the header using php explode () .. so I can combine middle words as well. I don’t know how to raise specific words in the title ... Help me .. Thanks in advance

+6
source share
2 answers

What you want gives more weight to the document with the shortest name. If two queries match your query, the one with the shortest heading means that it is still found with less information, so it should have a higher score.

What you can do is index time, set:

 weight = 1000 - number_of_characters_of_document_title (1000 or any other number : was just trying to have a positive weight) 
+1
source

You can try to complete two completion requests as follows:

 { "text": "inox", "suggestion_not_fuzzy": { "completion": { "field": "Suggest" } }, "suggestion_fuzzy": { "completion": { "field": "Suggest", "fuzzy": { "edit_distance": 1, "transpositions": true, "prefix_length": 1, "min_length": 4 } } } } 

and then try to get the results from "suggestion_not_fuzzy" if the reserve is empty on "suggestion_fuzzy"

0
source

Source: https://habr.com/ru/post/958401/


All Articles