Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example Analysis of Elasticsearch Mapping parameters fields

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "Elasticsearch mapping parameters fields instance analysis", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Elasticsearch mapping parameters fields instance analysis" article.

Elasticsearch mapping parameter fieldsfields

It is often useful to index the same fields in different ways for different purposes. This is also the purpose of multi-fields. For example, a string field can be mapped as a text field for full-text search, or as a keyword field for sorting or aggregation.

PUT my_index {"mappings": {"_ doc": {"properties": {"city": {"type": "text", "fields": {"raw": {"type": "keyword"}

The note:city.raw field is the keyword version of the city field.

GET my_index/_search {"query": {"city": "york"}}, "sort": {"city.raw": "asc"}, "aggs": {"Cities": {"terms": {"field": "city.raw"}

The note:city field is used for full-text search.

Note:city.raw is used for sorting and aggregation.

Multiple fields cannot modify the original _ source field.

The fields setting allows different settings for fields with the same name in the same index. You can use the PUT mapping API to add new multiple fields to existing fields.

Multiple fields with multiple parses

Another application scenario for multi-fields is to use different methods to analyze the same fields in order to obtain better correlation.

PUT my_index {"mappings": {"_ doc": {"properties": {"text": {"type": "text", "fields": {"english": {"type": "text" Analyzer: "english"}

The note:text.field field uses the english parser.

Elasticsearch annotations achieve fieldsmapping effects: "label": {"type": "keyword", "fields": {"IKS": {"type": "text" "analyzer": "ikIndexAnalyzer"} @ Column (name = "tag") @ MultiField (mainField = @ Field (type = FieldType.Keyword), otherFields = {@ InnerField (suffix = "IKS", type = FieldType.Text, analyzer = "ikIndexAnalyzer") protected String label The above is the content of this article on "fields instance Analysis of Elasticsearch Mapping parameters". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report