Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not-analyze in ElasticSearch?

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".

like image 725
Alfe Avatar asked Aug 14 '13 15:08

Alfe


People also ask

What is analyzed and not analyzed in Elasticsearch?

analyzed -> more space on disk (LOT MORE if the analyze filds are big). analyzed -> more time for indexation. analyzed -> better for matching documents. not_analyzed -> less space on disk.

What is analyzed in Elasticsearch?

An analyzer in Elasticsearch uses three parts: a character filter, a tokenizer, and a token filter. All three together can configure a text field into a searchable format. The text values can be single words, emails, or program logs.

How do I remove a mapping field in Elasticsearch?

You cannot delete the status field from this mapping. If you really need to get rid of this field, you'll have to create another mapping without status field and reindex your data.


1 Answers

"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.

like image 101
Scott Rice Avatar answered Oct 09 '22 23:10

Scott Rice