Link Search Menu Expand Document Documentation Menu

印地语分析器

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

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

词干排除

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

PUT index_with_stem_exclusion_hindi_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_hindi_analyzer": {
          "type": "hindi",
          "stem_exclusion": ["अधिकार", "अनुमोदन"]
        }
      }
    }
  }
}

印地语分析器内部结构

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

  • 分词器:standard

  • 词元过滤器

    • 小写
    • 十进制数字
    • 关键词
    • 标准化(印度语系)
    • 标准化(印地语)
    • 停止词(印地语)
    • 词干提取器(印地语)

自定义印地语分析器

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

PUT /hindi-index
{
  "settings": {
    "analysis": {
      "filter": {
        "hindi_stop": {
          "type": "stop",
          "stopwords": "_hindi_"
        },
        "hindi_stemmer": {
          "type": "stemmer",
          "language": "hindi"
        },
        "hindi_keywords": {
          "type": "keyword_marker",
          "keywords": []
        }
      },
      "analyzer": {
        "hindi_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "decimal_digit",
            "hindi_keywords",
            "indic_normalization",
            "hindi_normalization",
            "hindi_stop",
            "hindi_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "hindi_analyzer"
      }
    }
  }
}

生成的词元

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

POST /hindi-index/_analyze
{
  "field": "content",
  "text": "छात्र भारतीय विश्वविद्यालयों में पढ़ते हैं। उनके नंबर १२३४५६ हैं।"
}

响应包含生成的词元

{
  "tokens": [
    {
      "token": "छातर",
      "start_offset": 0,
      "end_offset": 5,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "भारतिय",
      "start_offset": 6,
      "end_offset": 12,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "विशवविदयालय",
      "start_offset": 13,
      "end_offset": 28,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "पढ",
      "start_offset": 33,
      "end_offset": 38,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "नंबर",
      "start_offset": 49,
      "end_offset": 53,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "123456",
      "start_offset": 54,
      "end_offset": 60,
      "type": "<NUM>",
      "position": 8
    }
  ]
}
剩余 350 字符

有问题?

想要贡献?