您可以通过word_delimiter token filter实现您的要求。 这是我的设置
{
"settings": {
"analysis": {
"analyzer": {
"camel_analyzer": {
"tokenizer": "whitespace",
"filter": [
"camel_filter",
"lowercase",
"asciifolding"
]
}
},
"filter": {
"camel_filter": {
"type": "word_delimiter",
"generate_number_parts": false,
"stem_english_possessive": false,
"split_on_numerics": false,
"protected_words": [
"iPhone",
"WiFi"
]
}
}
}
},
"mappings": {
}
}
这将分裂的话就情况变化所以NullPointerException
将被标记化作为空,指针和例外但iPhone和无线仍将作为这是因为他们是保护。 word_delimiter
有很多灵活性选项。你也可以preserve_original这将帮助你很多。
GET logs_index/_analyze?text=iPhone&analyzer=camel_analyzer
结果
{
"tokens": [
{
"token": "iphone",
"start_offset": 0,
"end_offset": 6,
"type": "word",
"position": 1
}
]
}
现在用
GET logs_index/_analyze?text=NullPointerException&analyzer=camel_analyzer
结果
{
"tokens": [
{
"token": "null",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 1
},
{
"token": "pointer",
"start_offset": 4,
"end_offset": 11,
"type": "word",
"position": 2
},
{
"token": "exception",
"start_offset": 11,
"end_offset": 20,
"type": "word",
"position": 3
}
]
}
另一种方法是用不同的分析仪两次分析自己的领域,但我觉得word_delimiter会做招。
这有帮助吗?
什么不使用小写过滤器?它将小写所有单词 – ChintanShah25
@ ChintanShah25这如何帮助修复tokenizer? (和顺便说一句 - 我使用小写字母过滤器) – tishma
标记化器不同于过滤器。 iPhone将被索引为带有小写过滤器的iphone。它会帮助,如果你发布你现在的anlayzer和映射 – ChintanShah25