首先,我是elasticsearch的新手,可能没有使用过所有可能的方法
我的文件有“汽车租赁”,“汽车租赁”,“汽车租赁机场租车”,“租车丰田汽车”等。 ,' ca' ca test'' ca test1',' ca test2'' test3 ca', ' test4 ca'等等 每当我运行像
这样的查询时['查询' => ['术语' => [' fld_name' => ' CA']]] 我得到CA作为回报。
但是,每当我尝试使用(word + space)执行查询时,如:
['查询' => ['术语' => [' fld_name' => ' ca']]] //这不会返回任何值,因为它与精确值匹配 ['查询' => ['匹配' => [' fld_name' => ' ca']]] //这会返回类似于'汽车租赁等的值。和雇用丰田汽车'以及..
在这里,我期待它返回ca测试,ca test1,ca test2,' test3 ca',' test4 ca' ..
我已经尝试过几乎所有类型的查询,例如query_string,match,match_phrase,match_phrase_prefix但是没有让它工作..
我的问题不仅限于单字搜索,它可以包含[两个字+空格],如
['查询' => ['匹配' => [' fld_name' => '租车']]] //这不应该归还'汽车租用'
请帮助.. !!
以下是示例设置和映射
"settings": {
"number_of_shards": "5",
"analysis": {
"char_filter": {
"punctuation": {
"pattern": "[\\.,]",
"type": "pattern_replace"
}
},
"analyzer": {
"search_partial": {
"filter": [
"word_delimiter",
"lowercase",
"asciifolding",
"unique"
],
"char_filter": [
"punctuation"
],
"type": "custom",
"tokenizer": "standard"
},
"search_all": {
"filter": [
"word_delimiter",
"lowercase",
"asciifolding",
"unique"
],
"char_filter": [
"punctuation"
],
"type": "custom",
"tokenizer": "standard"
},
},
},
"number_of_replicas": "0"
}
"mappings": {
"index_type": {
"_all": { "enabled": false },
"properties": {
"id": { "type": "integer" },
"fld_name": {
"type": "text",
"fields": {
"partial_front": {
"type": "text",
"analyzer": "partial_name_index",
"search_analyzer": "search_partial"
},
"exact": {
"type": "keyword"
},
"raw": {
"type": "text",
"analyzer": "raw_data_index"
}
},
"analyzer": "full_name_index",
"search_analyzer": "search_all"
}
}
}
}