分词器的组成
-
analyze 测试分词器
测试分词器
测试指定字段上的分词器
测试自定义分词器
es自带的分词器
standard是按空格或一些特殊字符切分(保留数字)
- simple是按照非字母规则切分
stop analyzer = simple + Stop Token Filter
standard analyzer
standard token filter现在什么都没做
ik中文分词最佳实践
- ik_smart:智能分词(查询分词用)
- ik_max_word:尽最大努力分词(构建索引用)
如果上述方案不行,则降级都使用ik_max_word。
自定义分词器
character filter
mapping 【敏感词过滤】
tokenizer
token filter
ngram【可用于自动补全功能】
自定义分词器
不需要分词的字段type设置为keyword
自定义同义词
索引时分词&查询时分词
不指定查询分词器就使用索引分词器。
建议:
- 不需要分词,就type设置为keywords