在弹性中搜索特殊字符

时间:2017-04-11 08:55:45

标签: elasticsearch

我的索引中有一个字段name,其值为$$$ LTD 标准分析仪适用于该领域。

我正在尝试使用此值搜索记录,但未找到任何内容。

http://localhost:9200/my-index/_search?q=name:$$$

在我搜索name:"$$$ LTD"的同一时间,它会返回包含LTD的所有记录,就像忽略$$$一样。

我很确定索引中存在适当的值。那么我该如何搜索呢?

UPD。 与可搜索字段相关的映射:

{“name":{"type":"string","boost":4.0,"analyzer”:”nameAnalyzer"}

{"nameAnalyzer":{"filter":["lowercase"],"type":"custom","tokenizer":"standard"}}}

2 个答案:

答案 0 :(得分:0)

在您的网址参数中不使用特殊字符($)。对于Ex,请使用它的编码。 $的编码是%24,所以请使用这种方式。

http://localhost:9200/my-index/_search?q=name:%24%24%24

答案 1 :(得分:0)

解决。 标准标记器会删除特殊字符。

我必须定义不同类型的tokeniser(可能是基于空间的)。 有关此问题的更多信息,请参见页面: https://discuss.elastic.co/t/how-to-index-special-characters-and-search-those-special-characters-in-elasticsearch/42506/2