elasticsearch - 自动完成 "smart"

标签 elasticsearch

我是否应该构建一个自动完成的“智能”,因为每个结果都必须隐藏在一系列信息之后。

例如:

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

如果找到,需要统计“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/

相关文章:

c# - Elasticsearch 中的分组

elasticsearch - 如何在 Elasticsearch 中按月分组

elasticsearch - 如何同时使用 Elasticsearch 的 geo_point 和 geo_shape 类型?

elasticsearch - Elasticsearch多重匹配字段不包含查询字符串

exception - NoSuchMethodError:org.apache.spark.sql.SQLContext.sql

elasticsearch - 在Elasticsearch查询中返回不匹配ID的列表

performance - Elasticsearch使用IN查询和评分会降低结果

ruby - Elasticsearch过滤最大值文档

python - 如何在python中为ElasticSearch创建只读客户端?

elasticsearch - 计算 Elasticsearch 中有多少文档具有某个属性或缺少该属性