Link Search Menu Expand Document Documentation Menu

保加利亚语分析器

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

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

词干排除

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

PUT index_with_stem_exclusion_bulgarian_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_bulgarian_analyzer": {
          "type": "bulgarian",
          "stem_exclusion": ["авторитет", "одобрение"]
        }
      }
    }
  }
}

保加利亚语分析器内部机制

bulgarian 分析器由以下组件构建而成

  • 分词器:standard

  • 词元过滤器

    • lowercase
    • stop (保加利亚语)
    • keyword
    • stemmer (保加利亚语)

自定义保加利亚语分析器

您可以使用以下命令创建自定义保加利亚语分析器

PUT /bulgarian-index
{
  "settings": {
    "analysis": {
      "filter": {
        "bulgarian_stop": {
          "type": "stop",
          "stopwords": "_bulgarian_"
        },
        "bulgarian_stemmer": {
          "type": "stemmer",
          "language": "bulgarian"
        },
        "bulgarian_keywords": {
          "type":       "keyword_marker",
          "keywords":   [] 
        }
      },
      "analyzer": {
        "bulgarian_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "bulgarian_stop",
            "bulgarian_keywords",
            "bulgarian_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "bulgarian_analyzer"
      }
    }
  }
}

生成的词元

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

POST /bulgarian-index/_analyze
{
  "field": "content",
  "text": "Студентите учат в българските университети. Техните номера са 123456."
}

响应包含生成的词元

{
  "tokens": [
    {"token": "студент","start_offset": 0,"end_offset": 10,"type": "<ALPHANUM>","position": 0},
    {"token": "учат","start_offset": 11,"end_offset": 15,"type": "<ALPHANUM>","position": 1},
    {"token": "българск","start_offset": 18,"end_offset": 29,"type": "<ALPHANUM>","position": 3},
    {"token": "университят","start_offset": 30,"end_offset": 42,"type": "<ALPHANUM>","position": 4},
    {"token": "техн","start_offset": 44,"end_offset": 51,"type": "<ALPHANUM>","position": 5},
    {"token": "номер","start_offset": 52,"end_offset": 58,"type": "<ALPHANUM>","position": 6},
    {"token": "123456","start_offset": 62,"end_offset": 68,"type": "<NUM>","position": 8}
  ]
}
剩余 350 字符

有问题?

想贡献?