2017-07-26 4 views
0

「アドラー」を返す結果を探してここに https://www.elastic.co/guide/en/elasticsearch/guide/current/ngrams-compound-words.htmlelasticsearch nグラム例の明確化

引用された例を参照します。 "Adler"を検索すると、adl、dle、lerという3つの用語のクエリになります。

しかし、なぜzdlがその用語の1つではありませんが、 "Zdler" 「アドラー」の検索に一致するクエリを適用

GET /my_index/my_type/_search 
{ 
    "query": { 
     "match": { 
      "text": { 
      "query": "zdler" 
      } 
      } 
     } 
} 

はレコードを返します - 期待します。

しかし、 "Zdler"のmatchクエリでも(dleとlerが一致するため)レコードが返されます。でも「minimum_should_match」を設定:「100%」のレコードを返します - 「アドラー」の検索に長期的なクエリを適用

を期待できない何も返さない - どのように私はレコードのみを返す達成ん

POST /my_index/my_type/_search 
    { 
    "query": { 
     "term": { 
      "text": { 
      "value": "Adler" 
      } 
     } 
     } 
    } 

を期待していません「アドラー」を検索し、「ズドラー」を検索しない

"settings": { 
    "index": { 
    "number_of_shards": "5", 
    "provided_name": "my_index", 
    "creation_date": "1501069624443", 
    "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": "Z5BXi_RjTACzTsR_-Nu9tw", 
    "version": { 
     "created": "5040099" 
    } 
    } 
} 

、これらは

{ 
"my_index": { 
"mappings": { 
    "my_type": { 
    "properties": { 
     "text": { 
     "type": "text", 
     "analyzer": "trigrams" 
     } 
    } 
    } 
} 
+0

単に「dle」と「ler」も – Val

答えて

1

match queryがクエリを投げる前に、入力されたクエリのフィールドアナライザを適用するマッピングです。同様に入力用トークン( "zdler")が生成され、再び逆インデックスに一致します。しかし、入力値にフィールドアナライザを適用しないので、用語クエリの場合は同じではありません

一致クエリは、 " - " "a"、 "d"、 "l"、 "e" .....その逆インデックスと照合します。

は、ソリューションを検索するための標準的な解析を適用することで2つのクエリ

POST index5/_search 
{ 
    "query": { 
    "match": { 
     "text": "zdler" 
    } 
    } 
} 


POST index5/_search 
{ 
    "query": { 
    "term": { 
     "text": { 
     "value": "zdler" 
     } 
    } 
    } 
} 
+0

と一致しているため、あなたの答えに基づいていくつかの情報を追加しました。 – Akshata

+0

設定とマッピングを追加できますか? – user3775217

+0

に設定とマッピングが追加されました – Akshata

0

に従う理解するようにしてください。 以下のクエリはレコードを返し、 "zdler"を検索しても結果は返されません。

GET /my_index_2/my_type/_search 
{ 
"query": { 
    "match": { 
     "text": { 
      "query": "adler", 
      "analyzer": "standard" 
     } 
    } 
    } 
}