0
我有一個問題,如果'ford'在數據庫中,我搜索'forddddddd'它返回一個匹配。對於'fo'這樣的查詢,我有ngrams的子部分匹配,for',ford'但'forddddd'不應該匹配。可能是什麼問題?以下是我的設置,映射和查詢。ElasticSearch問題與匹配結果
設置:
settings: {
number_of_shards: 1,
analysis: {
filter: {
ngram_filter: {
type: 'edge_ngram',
min_gram: 2,
max_gram: 15
}
},
analyzer: {
ngram_analyzer: {
type: 'custom',
tokenizer: 'standard',
filter: [
'lowercase',
'ngram_filter'
]
}
}
}
}
映射:
mappings: [
{
name: 'car',
_all: {
type: 'string',
analyzer: 'ngram_analyzer'
},
properties: {
description: {
properties: {
name: {
type: 'string',
include_in_all: true,
term_vector: 'yes',
analyzer: 'ngram_analyzer'
},
model: {
type: 'string',
include_in_all: true,
term_vector: 'yes',
analyzer: 'ngram_analyzer'
}
}
}
}
}
]
查詢:
GET car/_search
{
"query": {
"match": {
"_all": {
"query": "Forddddddd"
}
}
}
}
這是行得通!謝謝:) – emarel
很高興我能幫忙! – ChintanShah25