Link Search Menu Expand Document Documentation Menu

泰语分析器

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

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

词干排除

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

PUT index_with_stem_exclusion_thai_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_thai_analyzer": {
          "type": "thai",
          "stem_exclusion": ["อำนาจ", "การอนุมัติ"]
        }
      }
    }
  }
}

泰语分析器内部

thai 分析器使用以下组件构建

  • 分词器:thai

  • 词元过滤器

    • 小写
    • 十进制数字
    • 停用词(泰语)
    • 关键字

自定义泰语分析器

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

PUT /thai-index
{
  "settings": {
    "analysis": {
      "filter": {
        "thai_stop": {
          "type": "stop",
          "stopwords": "_thai_"
        },
        "thai_keywords": {
          "type": "keyword_marker",
          "keywords": []
        }
      },
      "analyzer": {
        "thai_analyzer": {
          "tokenizer": "thai",
          "filter": [
            "lowercase",
            "decimal_digit",
            "thai_stop",
            "thai_keywords"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "thai_analyzer"
      }
    }
  }
}

生成的词元

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

POST /thai-index/_analyze
{
  "field": "content",
  "text": "นักเรียนกำลังศึกษาอยู่ที่มหาวิทยาลัยไทย หมายเลข 123456."
}

响应包含生成的词元

{
  "tokens": [
    {"token": "นักเรียน","start_offset": 0,"end_offset": 8,"type": "word","position": 0},
    {"token": "กำลัง","start_offset": 8,"end_offset": 13,"type": "word","position": 1},
    {"token": "ศึกษา","start_offset": 13,"end_offset": 18,"type": "word","position": 2},
    {"token": "มหาวิทยาลัย","start_offset": 25,"end_offset": 36,"type": "word","position": 5},
    {"token": "ไทย","start_offset": 36,"end_offset": 39,"type": "word","position": 6},
    {"token": "หมายเลข","start_offset": 40,"end_offset": 47,"type": "word","position": 7},
    {"token": "123456","start_offset": 48,"end_offset": 54,"type": "word","position": 8}
  ]
}
剩余 350 字符

有问题?

想贡献?