我会尽量保持简单,如果您需要更多说明,请告诉我,我会详细说明更好的答案。
“已分析”字段将使用您在映射中为该特定表定义的分析器创建一个标记。如果您使用默认分析器(当您引用没有特殊字符的内容时,可以说服务器 [1-9])使用默认分析器(alnum-lowercase word-braker(这不是它的基本名称))是去标记化:
this -> HelloWorld123
into -> token1:helloworld123
OR
this -> Hello World 123
into -> token1:hello && token2:world && token3:123
在这种情况下,如果您进行搜索:HeLlO,它将变为 ->“hello”,并且它将匹配此文档,因为存在标记“hello”。
在 not_analized 字段的情况下,它根本不应用任何标记器,您的标记就是您的关键字,因此可以这么说:
this -> Hello World 123
into -> token1:(Hello World 123)
如果您在该字段中搜索“hello world 123”
不会匹配,因为它是“区分大小写”的(尽管 (Hello*),您仍然可以使用通配符,让我们在其他时间解决)。
简而言之:
对您要搜索的字段使用“已分析”字段,并且您希望 elasticsearch 对它们进行评分。例如:包含单词“jobs”的标题。查询:“标题:工作”。
doc1 : title:developer jobs in montreal
doc2 : title:java coder jobs in vancuver
doc3 : title:unix designer jobs in toronto
doc4 : title:database manager vacancies in montreal
这将检索title1 title2 title3。
在这种情况下,“分析”字段就是您想要的。
如果您事先知道该字段上的数据类型,并且您将准确查询您想要的内容,那么“not_analyzed”就是您想要的。
示例:
从 server123 获取所有日志。
查询:“服务器:server123”。
doc1 :server:server123,log:randomstring,date:01-jan
doc2 :server:server986,log:randomstring,date:01-jan
doc3 :server:server777,log:randomstring,date:01-jan
doc4 :server:server666,log:randomstring,date:01-jan
doc5 :server:server123,log:randomstring,date:02-jan
仅来自 server1 和 server5 的结果。
我希望你明白这一点。正如我所说,保持简单就是你所需要的。
analyzed -> 更多磁盘空间(如果分析字段很大,则更多)。分析-> 更多时间进行索引。分析 -> 更好地匹配文档。
not_analyzed -> 磁盘空间减少。 not_analyzed -> 更少的索引时间。 not_analyzed -> 完全匹配字段或使用通配符。
问候,
丹尼尔