我正在使用邊緣ngram tokenizer,以提供部分匹配。 我的文件看起來像問題與edge_ngram tokenizer IN彈性搜索
Name
Labson series LTD 2014
Labson PLO LTD 2014A
Labson PLO LTD 2014-I
Labson PLO LTD. 2014-II
我的映射如下
PUT my_index
{
"settings": {
"analysis": {
"analyzer": {
"autocomplete": {
"tokenizer": "autocomplete",
"filter": [
"lowercase"
]
},
"autocomplete_search": {
"tokenizer": "lowercase"
}
},
"tokenizer": {
"autocomplete": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 40,
"token_chars": [
"letter",
"digit"
]
}
}
}
},
"mappings": {
"doc": {
"properties": {
"title": {
"type": "string",
"analyzer": "autocomplete",
"search_analyzer": "autocomplete_search"
}
}
}
}
}
PUT my_index/doc/1
{
"title": "Labson Series LTD 2014"
}
PUT my_index/doc/2
{
"title": "Labson PLO LTD 2014A"
}
PUT my_index/doc/3
{
"title": "Labson PLO LTD 2014-I"
}
PUT my_index/doc/4
{
"title": "Labson PLO LTD. 2014-II"
}
下面的查詢給了我3個文件是正確的(Labson PLO LTD 2014A
,Labson PLO LTD 2014-I
,Labson PLO LTD. 2014-II
)
GET my_index/_search
{
"query": {
"match": {
"title": {
"query": "labson plo",
"operator": "and"
}
}
}
}
但是,當我輸入Labson PLO 2014A
它給我0文件
GET my_index/_search
{
"query": {
"match": {
"title": {
"query": "Labson PLO 2014A",
"operator": "and"
}
}
}
}
我希望這會返回1個文檔Labson PLO LTD 2014A
,但由於某種原因,它似乎不索引令牌中的數字。讓我知道如果我在這裏錯過任何東西。