我是否应该构建一个自动完成的“智能”,因为每个结果都必须隐藏在一系列信息之后。
例如:
我正在寻找“博洛尼亚”,我必须运行一个查询(或多个查询,我正在寻找一种尽可能少的方法),在“名称”字段中搜索“博洛尼亚”, “地方”和“地区”。
如果找到,需要统计“bologna”中有多少个结构。
这是数据库架构:
index:
analysis:
analyzer:
custom_search_analyzer:
type: custom
tokenizer: standard
filter : [standard, snowball, lowercase, asciifolding]
custom_index_analyzer:
type: custom
tokenizer: standard
filter : [standard, snowball, lowercase, asciifolding, custom_filter]
filter:
custom_filter:
type: edgeNGram
side: front
min_gram: 1
max_gram: 20
{
"structure": {
"properties": {
"name": {"type": "string", "search_analyzer": "custom_search_analyzer", "index_analyzer": "custom_index_analyzer"},
"locality": {"type": "string", "search_analyzer": "custom_search_analyzer", "index_analyzer": "custom_index_analyzer"},
"province": {"type": "string", "search_analyzer": "custom_search_analyzer", "index_analyzer": "custom_index_analyzer"},
"region": {"type": "string", "search_analyzer": "custom_search_analyzer", "index_analyzer": "custom_index_analyzer"}
}
}
}
显然,我可以在服务器端执行此操作,例如使用带循环的 php,但答案会非常慢,并且对 elasticsearch 的所有速度感到沮丧。
在这一点上,我想知道我该如何做到这一点。
最佳答案
我用过 this guide成功地解决了您提到的多领域需求。
关于elasticsearch - 自动完成 "smart",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21768298/