简体   繁体   English

如何在弹性搜索中搜索带有“-”字符的字段

[英]How to search fields with '-' characters in elastic search

I am new to elastic search. 我是弹性搜索的新手。 I have got following document where one of the field "eventId" has "-" in value. 我有以下文档,其中“ eventId”字段之一的值为“-”。 When i try to search with complete value of eventId, i don't get any results. 当我尝试使用eventId的完整值搜索时,我没有任何结果。

Sample Document app/event
 {
     "tags": {}
         "eventId": "cc98d57b-c6bc-424c-b54c-df1e3df0d942",
 }

I haven't created any explicit settings for my index. 我尚未为索引创建任何显式设置。 Thanks. 谢谢。

you should check if the tokenizer splits your value into multiple fields. 您应该检查令牌生成器是否将您的值划分为多个字段。 Maybe your value is stored as 5 fields: "cc98d57b", "c6bc", "424c", "b54c" and "df1e3df0d942" 也许您的值存储为5个字段:“ cc98d57b”,“ c6bc”,“ 424c”,“ b54c”和“ df1e3df0d942”

You can analyze that with the 'Kopf' Plugin ( https://github.com/lmenezes/elasticsearch-kopf ). 您可以使用“ Kopf”插件( https://github.com/lmenezes/elasticsearch-kopf )进行分析。

If that is your problem you should change your field mapping, so that the value is not analyzed ("index" : "not_analyzed"). 如果这是您的问题,则应更改字段映射,以便不分析该值(“ index”:“ not_analyzed”)。

For an example how to set that mapping see here: Elasticsearch mapping settings 'not_analyzed' and grouping by field in Java 有关如何设置该映射的示例,请参见此处: Elasticsearch映射设置“ not_analyzed”并按Java中的字段分组

After that, you should be able to search for your specific value. 之后,您应该可以搜索您的特定值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM