使用Word nGrams的多字词术语向量?

ev0*_*n37 3 n-gram elasticsearch term-vectors

我的目标是构建一个索引,对于每个文档,将通过单词ngrams(uni,bi和tri)将其分解,然后捕获所有这些单词ngrams上的术语向量分析.Elasticsearch可以吗?

例如,对于包含"红色汽车驱动器"的文档字段.我将能够获得这些信息:

red - 1 instance
car - 1 instance
drives - 1 instance
red car - 1 instance
car drives - 1 instance
red car drives - 1 instance
Run Code Online (Sandbox Code Playgroud)

提前致谢!

vie*_*rja 6

假设您已经了解Term Vectors api,您可以在索引时应用shingle令牌过滤器,以便在令牌流中将这些术语添加为彼此独立.

设置min_shingle_size为1(而不是默认值2),并max_shingle_size设置为至少3(而不是默认值2)

并且基于您从可能的术语中删除"the"这一事实,您应该在应用带状疱疹过滤之前使用停用词过滤器.

分析仪设置如下:

{
  "settings": {
    "analysis": {
      "analyzer": {
        "evolutionAnalyzer": {
          "tokenizer": "standard",
          "filter": [
            "standard",
            "lowercase",
            "custom_stop",
            "custom_shingle"
          ]
        }
      },
      "filter": {
        "custom_stop": {
            "type": "stop",
            "stopwords": "_english_",
            "enable_position_increments":"false"
        },
        "custom_shingle": {
            "type": "shingle",
            "min_shingle_size": "1",
            "max_shingle_size": "3"
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

您可以使用_analyzeapi端点测试分析仪.