如何在ElasticSearch中进行不分析? [英] How to not-analyze in ElasticSearch?

查看:305
本文介绍了如何在ElasticSearch中进行不分析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ElasticSearch领域有一个字段,我不想分析,我。即应逐字存储和比较。这些值将包含字母,数字,空格,破折号,斜杠以及其他字符。



如果我在此字段的映射中不给出分析器,则默认值使用一个将我的逐字符串字符串拼写成单词的标记器。我不想要这个。



有没有一个超简单的分析仪,基本上不分析?或者有不同的方式表示这个领域不会被分析?



我只创建索引,我不做任何其他事情。我可以使用像english这样的分析仪,其他字段似乎是预先配置的分析仪的内置名称。有没有其他名字的列表?也许有一个适合我的需要(即没有输入任何东西)。



这是我目前的映射:

  {
my_type:{
properties:{
my_field1:{type:string,analyzer english},
my_field2:{type:string}
}
}
}
pre>

my_field1 与语言有关;这似乎工作。 my_field2 应逐字进行。我想给一个分析器,根本不做任何事情。



my_field2 的示例值将B45c 14/04

解决方案

 code>my_field2:{
properties:{
title:{
type:string,
index:not_analyzed
}
}
}

a href =https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-core-types.html =nofollow noreferrer> https://www.elastic.co/guide /en/elasticsearch/reference/1.4/mapping-core-types.html ,了解更多信息。


I've got a field in an ElasticSearch field which I do not want to have analyzed, i. e. it should be stored and compared verbatim. The values will contain letters, numbers, whitespace, dashes, slashes and maybe other characters.

If I do not give an analyzer in my mapping for this field, the default still uses a tokenizer which hacks my verbatim string into chunks of words. I don't want that.

Is there a super simple analyzer which, basically, does not analyze? Or is there a different way of denoting that this field shall not be analyzed?

I only create the index, I don't do anything else. I can use analyzers like "english" for other fields which seems to be built-in names for pre-configured analyzers. Is there a list of other names? Maybe there's one fitting my needs (namely doing nothing with the input).

This is my mapping currently:

{
  "my_type": {
    "properties": {
      "my_field1": { "type": "string", "analyzer": "english" },
      "my_field2": { "type": "string" }
    }
  }
}

my_field1 is language-dependent; this seems to work. my_field2 shall be verbatim. I'd like to give an analyzer there which simply does not do anything.

A sample value for my_field2 would be "B45c 14/04".

解决方案

"my_field2": {
    "properties": {
        "title": {
            "type": "string",
            "index": "not_analyzed"
        }
    }
}

Check you here, https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-core-types.html, for further info.

这篇关于如何在ElasticSearch中进行不分析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆