6

我知道您可以使用构面在索引中找到最常用的术语。

例如以下输入:

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

术语方面返回:

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

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

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

....etc...

ElasticSearch 中有这样的功能吗?

4

2 回答 2

1

正如 ramseykhalaf 的评论中提到的,一个 shingle 过滤器会产生长度为“n”个单词的标记。

"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"
           }
       }
   }
}

有关完整详细信息,请参阅此博客文章

于 2013-08-15T15:26:04.067 回答
1

我不确定 elasticsearch 是否会让你以你想要的方式做这件事。但是您可能有兴趣查看 Carrot2 - http://search.carrot2.org 以完成您想要的(可能还有更多。)

于 2015-02-08T09:00:18.430 回答