首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >文本块上的word_delimiter

文本块上的word_delimiter
EN

Stack Overflow用户
提问于 2016-05-10 20:11:14
回答 1查看 25关注 0票数 1

看来,word_delimiter的设计只适用于单个术语。如果我有像下面这样的一段文字呢:

代码语言:javascript
复制
 "Contra-indications of paracetamol can be of certain sorts"

在这种情况下,word_delimiter获取整个句子并将其连接起来,而我只需要它连接"Contra-indications",以便在文本块内搜索contra indicationscontra-indicationscontraindications

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-11 01:30:11

你需要一个像这样的分析仪:

代码语言:javascript
复制
{
  "settings": {
    "analysis": {
      "filter": {
        "delimiter_filter": {
          "type": "word_delimiter",
          "catenate_words": true,
          "preserve_original": true
        }
      },
      "analyzer": {
        "delimiter_analyzer": {
          "type": "custom",
          "tokenizer": "whitespace",
          "filter": [
            "lowercase",
            "delimiter_filter"
          ]
        }
      }
    }
  },
  "mappings": {
    "assets": {
      "properties": {
        "domain": {
          "type": "string",
          "analyzer": "delimiter_analyzer"
        }
      }
    }
  }
}

对于示例文本-- Contra-indications of paracetamol can be of certain sorts --这些都是它生成的术语:

代码语言:javascript
复制
           "domain": [
              "be",
              "can",
              "certain",
              "contra",
              "contra-indications",
              "contraindications",
              "indications",
              "of",
              "paracetamol",
              "sorts"
           ]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37148057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档