Link Search Menu Expand Document Documentation Menu

拉脱维亚语分析器

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

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

词干排除

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

PUT index_with_stem_exclusion_latvian_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_latvian_analyzer": {
          "type": "latvian",
          "stem_exclusion": ["autoritāte", "apstiprinājums"]
        }
      }
    }
  }
}

拉脱维亚语分析器内部结构

拉脱维亚语分析器是使用以下组件构建的

  • 分词器:standard

  • 词元过滤器

    • 小写
    • 停止词 (拉脱维亚语)
    • 关键词
    • 词干提取器 (拉脱维亚语)

自定义拉脱维亚语分析器

您可以使用以下命令创建自定义拉脱维亚语分析器

PUT /italian-index
{
  "settings": {
    "analysis": {
      "filter": {
        "italian_stop": {
          "type": "stop",
          "stopwords": "_italian_"
        },
        "italian_elision": {
          "type": "elision",
          "articles": [
                "c", "l", "all", "dall", "dell",
                "nell", "sull", "coll", "pell",
                "gl", "agl", "dagl", "degl", "negl",
                "sugl", "un", "m", "t", "s", "v", "d"
          ],
          "articles_case": true
        },
        "italian_stemmer": {
          "type": "stemmer",
          "language": "light_italian"
        },
        "italian_keywords": {
          "type": "keyword_marker",
          "keywords": []
        }
      },
      "analyzer": {
        "italian_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "italian_elision",
            "lowercase",
            "italian_stop",
            "italian_keywords",
            "italian_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "italian_analyzer"
      }
    }
  }
}

生成的词元

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

POST /latvian-index/_analyze
{
  "field": "content",
  "text": "Studenti mācās Latvijas universitātēs. Viņu numuri ir 123456."
}

响应包含生成的词元

{
  "tokens": [
    {"token": "student","start_offset": 0,"end_offset": 8,"type": "<ALPHANUM>","position": 0},
    {"token": "māc","start_offset": 9,"end_offset": 14,"type": "<ALPHANUM>","position": 1},
    {"token": "latvij","start_offset": 15,"end_offset": 23,"type": "<ALPHANUM>","position": 2},
    {"token": "universitāt","start_offset": 24,"end_offset": 37,"type": "<ALPHANUM>","position": 3},
    {"token": "vin","start_offset": 39,"end_offset": 43,"type": "<ALPHANUM>","position": 4},
    {"token": "numur","start_offset": 44,"end_offset": 50,"type": "<ALPHANUM>","position": 5},
    {"token": "123456","start_offset": 54,"end_offset": 60,"type": "<NUM>","position": 7}
  ]
}
剩余 350 字符

有问题?

想贡献?