Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type keyword and not analyzed, any difference?

Is there any difference between the "keyword" field type and a field that uses "not_analyzed" as analyzer in Elasticsearch? If there is one, when to use which?

like image 541
Haphil Avatar asked Jun 03 '16 06:06

Haphil


People also ask

What is difference between keyword and text in Elasticsearch?

The crucial difference between them is that Elasticsearch will analyze the Text before it's stored into the Inverted Index while it won't analyze Keyword type. Analyzed or not analyzed will affect how it will behave when getting queried.

What is keyword type in Elasticsearch?

The keyword family includes the following field types: keyword , which is used for structured content such as IDs, email addresses, hostnames, status codes, zip codes, or tags. constant_keyword for keyword fields that always contain the same value. wildcard for unstructured machine-generated content.

What is field keyword?

keyword field takes the same input and keeps as one large string, meaning it can be aggregated on, and you can use wildcard searches on it. Aggregatable means you can use it in aggregations in elasticsearch, which resembles a sql group by if you are familiar with that. In Kibana you would probably use the .


1 Answers

As can be seen in the breaking changes documentation, the keyword data type is a new data type coming up in ES 5. It aims at replacing the string fields with "index": "not_analyzed".

So in ES 1.x and 2.x, this declaration

"field": {
    "type": "string",
    "index": "not_analyzed"
}

is equivalent to this declaration in ES 5

"field": {
    "type": "keyword"
}

Similarly, the text data type will replace normal analyzed string fields, so in ES 1.x and 2.x, this declaration

"field": {
    "type": "string"
}

will equivalent to this declaration in ES 5

"field": {
    "type": "text"
}
like image 108
Val Avatar answered Oct 08 '22 06:10

Val