Link Search Menu Expand Document Documentation Menu

丹麦语分析器

内置的 danish 分析器可以使用以下命令应用于文本字段

PUT /danish-index
{
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "danish"
      }
    }
  }
}

词干排除

您可以使用以下命令将 stem_exclusion 与此语言分析器一起使用

PUT index_with_stem_exclusion_danish_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_danish_analyzer": {
          "type": "danish",
          "stem_exclusion": ["autoritet", "godkendelse"]
        }
      }
    }
  }
}

丹麦语分析器内部结构

danish 分析器是使用以下组件构建的

  • 分词器:standard

  • 词元过滤器

    • 小写
    • 停用词 (丹麦语)
    • 关键词
    • 词干提取器 (丹麦语)

自定义丹麦语分析器

您可以使用以下命令创建自定义丹麦语分析器

PUT /danish-index
{
  "settings": {
    "analysis": {
      "filter": {
        "danish_stop": {
          "type": "stop",
          "stopwords": "_danish_"
        },
        "danish_stemmer": {
          "type": "stemmer",
          "language": "danish"
        },
        "danish_keywords": {
          "type":       "keyword_marker",
          "keywords":   [] 
        }
      },
      "analyzer": {
        "danish_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "danish_stop",
            "danish_keywords",
            "danish_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "danish_analyzer"
      }
    }
  }
}

生成的词元

使用以下请求检查使用该分析器生成的词元

POST /danish-index/_analyze
{
  "field": "content",
  "text": "Studerende studerer på de danske universiteter. Deres numre er 123456."
}

响应包含生成的词元

{
  "tokens": [
    {
      "token": "stud",
      "start_offset": 0,
      "end_offset": 10,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "stud",
      "start_offset": 11,
      "end_offset": 19,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "dansk",
      "start_offset": 26,
      "end_offset": 32,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "universitet",
      "start_offset": 33,
      "end_offset": 46,
      "type": "<ALPHANUM>",
      "position": 5
    },
    {
      "token": "numr",
      "start_offset": 54,
      "end_offset": 59,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "123456",
      "start_offset": 63,
      "end_offset": 69,
      "type": "<NUM>",
      "position": 9
    }
  ]
}
剩余 350 字符

有问题?

想要贡献?