Link Search Menu Expand Document Documentation Menu

意大利语分析器

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

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

词干排除

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

PUT index_with_stem_exclusion_italian_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_italian_analyzer": {
          "type": "italian",
          "stem_exclusion": ["autorità", "approvazione"]
        }
      }
    }
  }
}

意大利语分析器内部

italian 分析器由以下组件构建

  • 分词器: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 /italian-index/_analyze
{
  "field": "content",
  "text": "Gli studenti studiano nelle università italiane. I loro numeri sono 123456."
}

响应包含生成的词元

{
  "tokens": [
    {"token": "student","start_offset": 4,"end_offset": 12,"type": "<ALPHANUM>","position": 1},
    {"token": "studian","start_offset": 13,"end_offset": 21,"type": "<ALPHANUM>","position": 2},
    {"token": "universit","start_offset": 28,"end_offset": 38,"type": "<ALPHANUM>","position": 4},
    {"token": "italian","start_offset": 39,"end_offset": 47,"type": "<ALPHANUM>","position": 5},
    {"token": "numer","start_offset": 56,"end_offset": 62,"type": "<ALPHANUM>","position": 8},
    {"token": "123456","start_offset": 68,"end_offset": 74,"type": "<NUM>","position": 10}
  ]
}
剩余 350 字符

有问题?

想要贡献?