elasticsearch中的mapping简介

Mapping

Mapping is the process of defining how a document should be mapped to the Search Engine, including its searchable characteristics such as which fields are searchable and if/how they are tokenized. In Elasticsearch, an index may store documents of different "mapping types". Elasticsearch allows one to associate multiple mapping definitions for each mapping type.

Explicit mapping is defined on an index/type level. By default, there isn’t a need to define an explicit mapping, since one is automatically created and registered when a new type or new field is introduced (with no performance overhead) and have sensible defaults. Only when the defaults need to be overridden must a mapping definition be provided.

Mapping Typesedit

Mapping types are a way to divide the documents in an index into logical groups. Think of it as tables in a database. Though there is separation between types, it’s not a full separation (all end up as a document within the same Lucene index).

Field names with the same name across types are highly recommended to have the same type and same mapping characteristics (analysis settings for example). There is an effort to allow to explicitly "choose" which field to use by using type prefix (my_type.my_field), but it’s not complete, and there are places where it will never work (like faceting on the field).

In practice though, this restriction is almost never an issue. The field name usually ends up being a good indication to its "typeness" (e.g. "first_name" will always be a string). Note also, that this does not apply to the cross index case.

Mapping APIedit

To create a mapping, you will need the Put Mapping API, or you can add multiple mappings when youcreate an index.

Global Settingsedit

The index.mapping.ignore_malformed global setting can be set on the index level to allow to ignore malformed content globally across all mapping types (malformed content example is trying to index a text string value as a numeric type).

The index.mapping.coerce global setting can be set on the index level to coerce numeric content globally across all mapping types (The default setting is true and coercions attempted are to convert strings with numbers into numeric types and also numeric values with fractions to any integer/short/long values minus the fraction part). When the permitted conversions fail in their attempts, the value is considered malformed and the ignore_malformed setting dictates what will happen next.

时间: 2024-12-28 15:27:09

elasticsearch中的mapping简介的相关文章

elasticsearch中的mapping映射配置与查询典型案例

elasticsearch中的mapping映射配置示例比如要搭建个中文新闻信息的搜索引擎,新闻有"标题"."内容"."作者"."类型"."发布时间"这五个字段:我们要提供"标题和内容的检索"."排序"."高亮"."统计"."过滤"等一些基本功能.ES提供了smartcn的中文分词插件,测试的话建议使用IK分

使用Elasticsearch中的copy_to来提高搜索效率

在今天的这个教程中,我们来着重讲解一下如何使用Elasticsearch中的copy来提高搜索的效率.比如在我们的搜索中,经常我们会遇到如下的文档: { "user" : "双榆树-张三", "message" : "今儿天气不错啊,出去转转去", "uid" : 2, "age" : 20, "city" : "北京", "provin

Elasticsearch中的CRUD

在<玩玩儿Elasticsearch>中简介了一下elasticsearch.这篇文章.我们还是做些基础的学习.在Elasticsearch怎样进行CRUD? 如果我们正在创建的一个类似微博的应用.我们就姑且先叫它"kiwi"吧.kiwi这个应用就是一条条消息组成的. 在kiwi中,消息称为ksay.有两个部分组成.一是作者(author),而是消息本身(message). Create curl -X POST http://localhost:9200/kiwi/ksa

ElasticSearch中的一些概念

索引词(term) 在elasticsearch中索引词(term)是一个能够被索引的精确值.foo,Foo Foo几个单词是不相同的索引词.索引词(term)是可以通过term查询进行准确的搜索. 文本(text) 文本是一段普通的非结构化文字,通常,文本会被分析称一个个的索引词,存储在elasticsearch的索引库中,为了让文本能够进行搜索,文本字段需要事先进行分析:当对文本中的关键词进行查询的时候,搜索引擎应该根据搜索条件搜索出原文本. 分析(analysis) 分析是将文本转换为索引

图解Elasticsearch中的_source、_all、store和index属性

Elasticsearch中有几个关键属性容易混淆,很多人搞不清楚_source字段里存储的是什么?store属性的true或false和_source字段有什么关系?store属性设置为true和_all有什么关系?index属性又起到什么作用?什么时候设置store属性为true?什么时候应该开启_all字段?本文通过图解的方式,深入理解Elasticsearch中的_source._all.store和index属性. 图1 Elasticsearch中的_source._all.stor

一文带您了解 Elasticsearch 中,如何进行索引管理(图文教程)

欢迎关注笔者的公众号: 小哈学Java, 每日推送 Java 领域干货文章,关注即免费无套路附送 100G 海量学习.面试资源哟!! 个人网站: https://www.exception.site/essay/about-elasticsearch-index-manage 在 Elasticsearch 中,索引是一个非常重要的概念,它是具有相同结构的文档集合.类比关系型数据库,比如 Mysql, 你可以把它对标看成和库同级别的概念. 今天小哈将带着大家了解, 在 Elasticsearch

Elasticsearch系列---定制mapping

概要 本篇接着前一篇内容,继续介绍mapping信息,重点倾向于自定义mapping.自定义对象以及数组集合类的底层结构. 自定义mapping 上一篇文章介绍的都是Elasticsearch的自动mapping,我们在创建索引时,可以先指定好mapping的信息,还是以music索引为例: PUT /music { "mappings": { "children": { "properties": { "content":

第三百六十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的mapping映射管理

第三百六十四节,Python分布式爬虫打造搜索引擎Scrapy精讲-elasticsearch(搜索引擎)的mapping映射管理 1.映射(mapping)介绍 映射:创建索引的时候,可以预先定义字段的类型以及相关属性elasticsearch会根据json源数据的基础类型猜测你想要的字段映射,将输入的数据转换成可搜索的索引项,mapping就是我们自己定义的字段数据类型,同时告诉elasticsearch如何索引数据以及是否可以被搜索 作用:会让索引建立的更加细致和完善 类型:静态映射和动态

c#中的数据类型简介(数组)

c#中的数据类型简介(数组) 数组定义 可以将数组看成相同数据类型的一组或多组数据,包括一维数组,多维数组和交错数组 数据申明 一维数组的几种申明和实例化 type[]  typeName = new type[n]:                                                //定义数组但是未赋值 type[0] = item1; type[1] = item2; type[2] = item3; ...... type[n-1] =itemn; type[