ELK-内置分词器-simple_pattern分词器
一.simple_pattern分词器
simple_pattern分词器是根据正则表达式进行分词的分词器
#创建映射并定义字段内容分词的正则表达式 #正则表达式表示,如果连续有3个数字在一起,则可以被当作一个单词 PUT myindex-simple_pattern { "settings": { "analysis": { "analyzer": { "my_analyzer": { "tokenizer":"my_tokenizer" } }, "tokenizer": { "my_tokenizer": { "type":"simple_pattern", "pattern":"[0123456789]{3}" } } } } } #对指定内容根据"myindex-simple_pattern"分词器进行分词 POST myindex-simple_pattern/_analyze { "analyzer":"my_analyzer", "text":"fd-123-4567-890-xxd9-689-x987" }
可以看到"fd-123-4567-890-xxd9-689-x987"被分成了5关键字,分词之后的结果如下
["123","456","890","689","987"]
![](https://img2022.cnblogs.com/blog/42037/202208/42037-20220822215145779-1416398986.png)
旧书不厌百回读,熟读深思子自知。