当我使用带有自定义分析器的字段时,logix_item_view_id:ebc1003mb不返回,仅当我仅使用logix_item_view_id搜索时,我才获得正确的结果。
我不明白,也不知道该怎么办? logix_item_view_id_search应该基于ngran逻辑返回类似的代码,因此我的搜索在某些方面是正确的,但为什么不返回代码ebc1003mb?在上面是我的索引设置和映射属性
我在elasticksearch中创建了一个具有以下属性的索引:
{
"items_production_20181008060000331": {
"settings": {
"index": {
"max_ngram_diff": "49",
"number_of_shards": "5",
"provided_name": "items_production_20181008060000331",
"max_shingle_diff": "4",
"max_result_window": "3000000",
"creation_date": "1538989200382",
"analysis": {
"filter": {
"searchkick_velow_ngram": {
"type": "edgeNGram",
"min_gram": "3",
"max_gram": "50"
},
"searchkick_edge_ngram": {
"type": "edgeNGram",
"min_gram": "1",
"max_gram": "50"
}
},
"analyzer": {
"searchkick_word_start_index": {
"filter": [
"lowercase",
"asciifolding",
"searchkick_edge_ngram"
],
"type": "custom",
"tokenizer": "standard"
},
"velow_word_start_index": {
"filter": [
"lowercase",
"asciifolding",
"searchkick_velow_ngram"
],
"type": "custom",
"tokenizer": "standard"
}
},
"char_filter": {
"ampersand": {
"type": "mapping",
"mappings": [
"&=> and "
]
}
}
},
"number_of_replicas": "1",
"uuid": "Goj0nb3JQguuPjWoE69XTg",
"version": {
"created": "6020399"
}
}
}
},
"readme": {
"settings": {
"index": {
"creation_date": "1536920464303",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "TfQpl9nDRHufZYT25N4n0Q",
"version": {
"created": "6040099"
},
"provided_name": "readme"
}
}
}
}
使用此设置:
GET items_production/_search?explain
{
"query": {
"bool": {
"must": {
"multi_match" : {
"query": "ebc1003mb",
"type": "cross_fields",
"fields": [
"logix_item_view_id^10",
"logix_item_view_id_search^9"
]
}
}
}
}
}
进行此搜索时,我没有得到应为第一项的任何结果:
GET items_production/_analyze
{
"analyzer" : "velow_word_start_index",
"text" : "ebc1003mb"
}
{
"tokens": [
{
"token": "ebc",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "ebc1",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "ebc10",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "ebc100",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "ebc1003",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "ebc1003m",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "ebc1003mb",
"start_offset": 0,
"end_offset": 9,
"type": "<ALPHANUM>",
"position": 0
}
]
}
这是我进行分析时得到的:
iconv
但不要误解我做错的事