如何在弹性搜索中找到最常用的短语? [英] How to find most used phrases in elasticsearch?

查看:190
本文介绍了如何在弹性搜索中找到最常用的短语?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以在使用方面的索引中找到使用最多的条款。

I know that you can find most used terms in an index with using facets.

例如,以下输入:

"A B C" 
"AA BB CC"
"A AA B BB"
"AA B"

术语facet返回:

B:3
AA:3
A:2
BB:2
CC:1
C:1

但我想知道是否可以列出以下内容:

But I'm wondering that is it possible to list followings:

AA B:2
A B:1
BB CC:1

....etc...

ElasticSearch中是否有这样的功能?

Is there such a feature in ElasticSearch?

推荐答案

如在ramseykhalaf的评论中所提到的,瓦楞过滤器将产生长度为n字的标记。

As mentioned in ramseykhalaf's comment, a shingle filter would produce tokens of length "n" words.

"settings" : { 
   "analysis" : {
       "filter" : {
          "shingle":{
              "type":"shingle",
              "max_shingle_size":5,
              "min_shingle_size":2,
              "output_unigrams":"true"
           },
           "filter_stop":{
              "type":"stop",
              "enable_position_increments":"false"
           }
       },
       "analyzer" : {
           "shingle_analyzer" : {
               "type" : "custom",
               "tokenizer" : "whitespace",
               "filter" : ["standard," "lowercase", "shingle", "filter_stop"]
           }
       }
   }
},
"mappings" : {
   "type" : {
       "properties" : {
           "letters" : {
               "type" : "string",
               "analyzer" : "shingle_analyzer"
           }
       }
   }
}

请参阅博客文章,了解详情。

这篇关于如何在弹性搜索中找到最常用的短语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆