Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boosting input fields for completion suggester

Im using completion suggester for 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 completion query as below

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

    }       
}

But here i am getting the output as

  1. CineMAX: Inorbit Mall, Cyberabad,
  2. INOX: Kolkata

I want to give more priority to exact match.. so i want INOX: Kolkata in the top..

I have splitted the title using php explode().. so i can match middle words also..I don know how to boost specific words in the title..Plz help me.. Thanks in advance

like image 810
Radhika.S Avatar asked Nov 19 '13 14:11

Radhika.S


1 Answers

You can try running two completion queries like this:

{
    "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 empty fallback to "suggestion_fuzzy"

like image 111
Sorin Neacsu Avatar answered Sep 21 '22 11:09

Sorin Neacsu