Link Search Menu Expand Document Documentation Menu

葡萄牙语(巴西)分析器

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

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

词干排除

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

PUT index_with_stem_exclusion_brazilian_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_brazilian_analyzer": {
          "type": "brazilian",
          "stem_exclusion": ["autoridade", "aprovação"]
        }
      }
    }
  }
}

葡萄牙语(巴西)分析器内部

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

  • 分词器:standard

  • 词元过滤器

    • 小写
    • 停用词(葡萄牙语(巴西))
    • 关键词
    • 词干提取器(葡萄牙语(巴西))

自定义葡萄牙语(巴西)分析器

您可以使用以下命令创建自定义的葡萄牙语(巴西)分析器

PUT /brazilian-index
{
  "settings": {
    "analysis": {
      "filter": {
        "brazilian_stop": {
          "type": "stop",
          "stopwords": "_brazilian_"
        },
        "brazilian_stemmer": {
          "type": "stemmer",
          "language": "brazilian"
        },
        "brazilian_keywords": {
          "type":       "keyword_marker",
          "keywords":   [] 
        }
      },
      "analyzer": {
        "brazilian_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "brazilian_stop",
            "brazilian_keywords",
            "brazilian_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "brazilian_analyzer"
      }
    }
  }
}

生成的词元

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

POST /brazilian-index/_analyze
{
  "field": "content",
  "text": "Estudantes estudam em universidades brasileiras. Seus números são 123456."
}

响应包含生成的词元

{
  "tokens": [
    {"token": "estudant","start_offset": 0,"end_offset": 10,"type": "<ALPHANUM>","position": 0},
    {"token": "estud","start_offset": 11,"end_offset": 18,"type": "<ALPHANUM>","position": 1},
    {"token": "univers","start_offset": 22,"end_offset": 35,"type": "<ALPHANUM>","position": 3},
    {"token": "brasileir","start_offset": 36,"end_offset": 47,"type": "<ALPHANUM>","position": 4},
    {"token": "numer","start_offset": 54,"end_offset": 61,"type": "<ALPHANUM>","position": 6},
    {"token": "sao","start_offset": 62,"end_offset": 65,"type": "<ALPHANUM>","position": 7},
    {"token": "123456","start_offset": 66,"end_offset": 72,"type": "<NUM>","position": 8}
  ]
}
剩余 350 字符

有问题?

想贡献?