Link Search Menu Expand Document Documentation Menu

希腊语分析器

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

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

词干排除

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

PUT index_with_stem_exclusion_greek_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_greek_analyzer": {
          "type": "greek",
          "stem_exclusion": ["αρχή", "έγκριση"]
        }
      }
    }
  }
}

希腊语分析器内部结构

greek 分析器由以下组件构建

  • 分词器:standard

  • 词元过滤器

    • 小写
    • 停用词 (希腊语)
    • 关键词
    • 词干提取器 (希腊语)

自定义希腊语分析器

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

PUT /greek-index
{
  "settings": {
    "analysis": {
      "filter": {
        "greek_stop": {
          "type": "stop",
          "stopwords": "_greek_"
        },
        "greek_stemmer": {
          "type": "stemmer",
          "language": "greek"
        },
        "greek_keywords": {
          "type": "keyword_marker",
          "keywords": []
        }
      },
      "analyzer": {
        "greek_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "greek_stop",
            "greek_keywords",
            "greek_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "greek_analyzer"
      }
    }
  }
}

生成的词元

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

POST /greek-index/_analyze
{
  "field": "content",
  "text": "Οι φοιτητές σπουδάζουν στα ελληνικά πανεπιστήμια. Οι αριθμοί τους είναι 123456."
}

响应包含生成的词元

{
  "tokens": [
    {"token": "φοιτητές","start_offset": 3,"end_offset": 11,"type": "<ALPHANUM>","position": 1},
    {"token": "σπουδάζ","start_offset": 12,"end_offset": 22,"type": "<ALPHANUM>","position": 2},
    {"token": "στα","start_offset": 23,"end_offset": 26,"type": "<ALPHANUM>","position": 3},
    {"token": "ελληνικά","start_offset": 27,"end_offset": 35,"type": "<ALPHANUM>","position": 4},
    {"token": "πανεπιστήμ","start_offset": 36,"end_offset": 48,"type": "<ALPHANUM>","position": 5},
    {"token": "αριθμοί","start_offset": 53,"end_offset": 60,"type": "<ALPHANUM>","position": 7},
    {"token": "τους","start_offset": 61,"end_offset": 65,"type": "<ALPHANUM>","position": 8},
    {"token": "είνα","start_offset": 66,"end_offset": 71,"type": "<ALPHANUM>","position": 9},
    {"token": "123456","start_offset": 72,"end_offset": 78,"type": "<NUM>","position": 10}
  ]
}
剩余 350 字符

有问题?

想要贡献?