1.简介
当自带的分词器无法满足需求时,就可以通过自定义分词来解决,自定义分词器的组成包括character filters、tokenizer和token filters三个部分。
2.Character Filters
(1).简介
在tokenizer之前对原始文本进行处理,比如增加、删除或者替换字符等,其会影响后续tokenizer解析的位置和偏移量,自带的三个功能为去除html标签和实体的html_strip、进行字符串替换操作的my_mapping(自定义)以及进行正则匹配替换的my_pattern(自定义)。
(2).query
3.Tokenizer
(1).简介
将原始文本按照一定规则切分为单词,自带的功能包括按单词分割的standard、按非字符分割的letter、按空格分割的whitespace以及按文件路径进行分割的path_hierarchy等。
(2).query
4.Token Filters
(1).简介
token filters对tokenizer的分词结果进行再加工操作,自带的功能包括将所有单词转为小写的lowercase、删除助词的stop以及添加近义词的synonym等。
(2).query
5.自定义分词
(1).简介
自定义分词需要在索引的配置中设置,只需要设置三个组成部分character filters、tokenizer和token filters即可。
(2).案例