这就是我用来在多字段Map中创建索引的方法
curl -X PUT http://localhost:9200/mapping_log
{ "mappings":{ "properties":{"data1:{"type": "text","fields":{"keyword":{"type":"keyword"}}}, {"data2":{"type": "text","fields":{"keyword":{"type":"keyword"}}}, {"data3":{"type": "text","fields":{"keyword":{"type":"keyword"}}}, } } }
这是我在ElasticSearch中的数据,我想做搜索,例如,当我搜索支持时,我应该得到值数据和服务器,当我搜索开发人员时,我应该得到地理位置和图形,我想要数据的建议者3,如果我输入g,那么我应该得到图形和地理的选项,有人能帮我吗。。
{
"took": 14,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 4,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "mapping_log",
"_type": "properties",
"_id": "1",
"_score": 1,
"_source": {
"data1": "support",
"data2": "data",
"data3": "datapos"
}
},
{
"_index": "mapping_log",
"_type": "properties",
"_id": "2",
"_score": 1,
"_source": {
"data1": "support",
"data2": "server",
"data3": "serverpos"
}
},
{
"_index": "mapping_log",
"_type": "properties",
"_id": "3",
"_score": 1,
"_source": {
"data1": "developer",
"data2": "graph",
"data3": "graphpos"
}
},
{
"_index": "mapping_log",
"_type": "properties",
"_id": "4",
"_score": 1,
"_source": {
"data1": "developer",
"data2": "geo",
"data3": "geopos"
}
}
]
}
}
1条答案
按热度按时间w46czmvw1#
您需要在源代码过滤的同时使用edge\ngram标记器
添加索引数据(与问题相同)、索引Map、搜索查询和搜索结果的工作示例
索引Map:
搜索查询:
当我搜索支持时,我应该得到数据和服务器的值
搜索结果:
搜索查询:
搜索结果:
搜索查询:
我想要数据3的建议,比如假设我输入g,那么我应该得到graph和geo选项
搜索结果:
更新1:
您可以根据需要更新索引Map