标记化后的 Elasticsearch 合并标记(术语)

问题描述 投票:0回答:1

我正在尝试找到一种解决方案,以在标记化后组合所有标记(术语)。

例如 - 此分析器(我的分析器)在应用“custom_stop”过滤器后生成 n 个标记。有什么方法可以组合所有令牌并生成一个令牌吗?

我见过“指纹”过滤器,它结合了所有标记,但它也进行排序,这是我不想要的。请为此提出解决方案。


 "analysis": {
      "analyzer": {
        "my-analyser": {
          "tokenizer": "standard",
          "filter": [ "custom_stop"]
        }
      },
      "filter": {
        "custom_stop": {
          "type": "stop",
          "ignore_case": true,
          "stopwords": [ "elastic", "aws", "java" ]
        }
}

对于输入-“这里讨论了 elastic aws java 中的概念” 它会产生这些标记 - [“概念”,“讨论”,“这里”],

我想结合这三个标记并生成一个标记,例如[“此处讨论的概念”]

elasticsearch elasticsearch-5
1个回答
0
投票
"analysis": {
  "analyzer": {
    "my-analyzer": {
      "tokenizer": "standard",
      "filter": [
        "custom_stop",
        "concatenate_tokens"
      ]
    }
  },
  "filter": {
    "custom_stop": {
      "type": "stop",
      "ignore_case": true,
      "stopwords": ["elastic", "aws", "java"]
    },
    "concatenate_tokens": {
      "type": "script",
      "script": "String.join(' ', tokens)"
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.