在使用以下请求创建索引后解决了许多问题之后,我成功创建了索引并添加了约1000项。我实现了自动完成,edgengram,模糊搜索和同义词搜索。似乎所有搜索除了同义词search以外都在工作。我在这里做错什么。
{
"settings": {
"index": {
"analysis": {
"filter": {
"synonym": {
"type": "synonym",
"format": "wordnet",
"synonyms_path": "analysis/wn_s.pl"
}
},
"analyzer": {
"synonym": {
"tokenizer": "standard",
"filter": ["synonym"]
},
"keyword_analyzer": {
"filter": [
"lowercase",
"asciifolding",
"trim"
],
"char_filter": [],
"type": "custom",
"tokenizer": "keyword"
},
"edge_ngram_analyzer": {
"filter": [
"lowercase"
],
"tokenizer": "edge_ngram_tokenizer"
},
"edge_ngram_search_analyzer": {
"tokenizer": "lowercase"
}
},
"tokenizer": {
"edge_ngram_tokenizer": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 25,
"token_chars": [
"letter"
]
}
},
"mappings": {
"properties": {
"firebaseId": {
"type": "text"
},
"name": {
"fielddata": true,
"type": "text",
"analyzer": "standard"
},
"name_auto": {
"type": "text",
"fields": {
"keywordstring": {
"type": "text",
"analyzer": "keyword_analyzer"
},
"edgengram": {
"type": "text",
"analyzer": "edge_ngram_analyzer",
"search_analyzer": "edge_ngram_search_analyzer"
},
"completion": {
"type": "completion"
},
"synonym_analyzer": {
"type": "synonym",
"analyzer": "synonym"
}
}
}
}
}
}
}
}
}
我的产品名称为“ long shirt”,所以当我在同义词搜索中搜索“ longy”时,并没有得到想要的结果。这是我的以下搜索请求:
{
"query" : {
"bool" : {
"should" : [
{
"match_phrase" : {
"name_auto.edgengram": "lengthy"
}
},{
"match_phrase" : {
"name_auto": "lengthy"
}
},{
"match" : {
"name_auto": "lengthy"
}
},
{
"match" : {
"name_auto.synonym_analyzer": "lengthy"
}
},{
"match" : {
"category_name": "lengthy"
}
},{
"match": {
"name": {
"query": "lengthy",
"fuzziness": 2,
"prefix_length": 1
}
}
}
]
}
}
}