Link Search Menu Expand Document Documentation Menu

立陶宛语分析器

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

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

词干排除

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

PUT index_with_stem_exclusion_lithuanian_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_lithuanian_analyzer": {
          "type": "lithuanian",
          "stem_exclusion": ["autoritetas", "patvirtinimas"]
        }
      }
    }
  }
}

立陶宛语分析器内部结构

内置的 lithuanian 分析器由以下组件构建而成

  • 分词器:standard

  • 词元过滤器

    • 小写
    • 停用词 (立陶宛语)
    • 关键词
    • 词干提取器 (立陶宛语)

自定义立陶宛语分析器

您可以使用以下命令创建自定义立陶宛语分析器

PUT /lithuanian-index
{
  "settings": {
    "analysis": {
      "filter": {
        "lithuanian_stop": {
          "type": "stop",
          "stopwords": "_lithuanian_"
        },
        "lithuanian_stemmer": {
          "type": "stemmer",
          "language": "lithuanian"
        },
        "lithuanian_keywords": {
          "type": "keyword_marker",
          "keywords": []
        }
      },
      "analyzer": {
        "lithuanian_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "lithuanian_stop",
            "lithuanian_keywords",
            "lithuanian_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "lithuanian_analyzer"
      }
    }
  }
}

生成的词元

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

POST /lithuanian-index/_analyze
{
  "field": "content",
  "text": "Studentai mokosi Lietuvos universitetuose. Jų numeriai yra 123456."
}

响应包含生成的词元

{
  "tokens": [
    {"token": "student","start_offset": 0,"end_offset": 9,"type": "<ALPHANUM>","position": 0},
    {"token": "mok","start_offset": 10,"end_offset": 16,"type": "<ALPHANUM>","position": 1},
    {"token": "lietuv","start_offset": 17,"end_offset": 25,"type": "<ALPHANUM>","position": 2},
    {"token": "universitet","start_offset": 26,"end_offset": 41,"type": "<ALPHANUM>","position": 3},
    {"token": "num","start_offset": 46,"end_offset": 54,"type": "<ALPHANUM>","position": 5},
    {"token": "123456","start_offset": 59,"end_offset": 65,"type": "<NUM>","position": 7}
  ]
}
剩余 350 字符

有问题?

想贡献?