2014-02-14 55 views
5

我应该建立一个自动填充“智能”,因为每一个结果都必须穿在一系列信息的后面。自动填充“智能”

例如:

我找“博洛尼亚”和我要运行一个查询(或不止一个,我一直在寻找一种方法,使之尽可能少),其中“博洛尼亚”是在“名称”,“地点”和“地区”字段中搜索。

如果发现,需要计算“博洛尼亚”中有多少结构。

这是数据库模式:

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的所有速度。

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

+0

你看过完成建议吗? http://www.elasticsearch.org/blog/you-complete-me/ – javanna

+0

是的,我已经看到建议elasticsearch,但正如我在问题中所述,我需要更多的数据比在搜索中简单的自动完成。这个建议弹性搜索的东西是不可能的。或者至少我不知道方式。 – Lughino

+0

没有完全理解你在问什么。完成建议器中的“有效载荷”是否可以解决您的问题? http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html – Sangharsh

回答

0

我已经成功地使用了this guide,它解决了您提到的多领域需求。