2016-07-27 9 views
0

Ich habe eine Felder mit dem Namen Titel mit der folgenden Zuordnung.Elasticsearch Begriff Suggester funktioniert nicht wie erwartet

{ 
"title": { 
    "type": "string" 
} 

Während der Begriff Suggester für Rechtschreibprüfung, gibt es nicht Ergebnis wie erwartet.

Für die Abfrage lenovo a1000 gibt es Ergebnisse wie folgt zurück.

[spell_suggestion] => Array 
     (
      [0] => Array 
       (
        [text] => lenovo 
        [offset] => 0 
        [length] => 6 
        [options] => Array 
         (
         ) 

       ) 

      [1] => Array 
       (
        [text] => a1000 
        [offset] => 7 
        [length] => 5 
        [options] => Array 
         (
          [0] => Array 
           (
            [text] => a1018 
            [score] => 0.6 
            [freq] => 1 
           ) 

          [1] => Array 
           (
            [text] => a102 
            [score] => 0.5 
            [freq] => 1 
           ) 

          [2] => Array 
           (
            [text] => a104 
            [score] => 0.5 
            [freq] => 1 
           ) 

          [3] => Array 
           (
            [text] => a108 
            [score] => 0.5 
            [freq] => 1 
           ) 

         ) 

       ) 

     ) 

) 

Aber der Index hat Titel enthält lenovo a1000.

Ich verwende die folgende Abfrage für die Rechtschreibprüfung.

{ 
    "spell_suggestion": { 
     "text": "lenovo a1000", 
     "term": { 
      "field": "title", 
      "sort": "score", 
      "prefix_length": 3 
     } 
    } 
} 

Warum gibt Elasticsearch die Begriffe nicht bereits im Index zurück. Mache ich etwas falsch oder fehlt ?. Bitte vorschlagen.

Antwort

0

Es gibt eine Option suggest_mode, die standardmäßig auf:

missing: Only provide suggestions for suggest text terms that are not in the index. This is the default. 

versuchen, es so zu ändern:

always: Suggest any matching suggestions based on terms in the suggest text. 

Ref: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-term.html#_common_suggest_options

+0

ich, dass auch versucht. Aber auch nicht geben den Text bereits im Index vorhanden. –