自动完成"智能"

Lug*_*ino 5 elasticsearch

我是否应该建立一个自动完成"智能",因为每个结果都必须在一系列信息背后.

例如:

我正在寻找"博洛尼亚",我必须运行一个查询(或多个,我正在寻找一种尽可能少的方法),在"名称","地点"字段中搜索"博洛尼亚"和"地区".

如果找到,有必要计算"博洛尼亚"中有多少结构.

这是数据库架构:

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"}
   }
 }
}
Run Code Online (Sandbox Code Playgroud)

显然我可以在服务器端执行此操作,例如使用带循环的php,但答案非常缓慢,并且对弹性搜索的所有速度感到沮丧.

在这一点上,我想知道如何做到这一点.

era*_*ran 0

我已经成功地使用了本指南,它解决了您提到的多字段要求。