elasticsearch中的mapping简介
2015-09-28 00:00
501 查看
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
Theindex.mapping.ignore_malformedglobal 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.coerceglobal 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.
相关文章推荐
- iOS9系列专题四——APP传输安全
- context和Applicaion的作用
- swift中value type和reference type
- web app和native app的区别
- Android_设置透明ActionBar
- [iOS开发项目-3] 按钮控件的移动,放大缩小,左右旋转操作
- Mac 环境下 Jenkins+Gradle 配制android 持续构建总结
- Android 方法数超过限制的解决办法
- iOS-监听触摸事件的几种方式
- iOS 全局禁止横屏,但UIWebView 全屏横屏播放视频的解决办法
- OC-NSSTRING-NSMUTABLENSTRING
- Android下Xml解析技术(四)、pull生成Xml文件
- Android下Xml解析技术(三)、pull解析Xml文件
- iOS 静态库开发
- Android下Xml解析技术(二)、DOM解析Xml文件
- Android下Xml解析技术(一)、SAX解析Xml文件
- Android android:gravity和android:layout_gravity的区别
- android ListView向上滑动隐藏标题,下拉显示标题栏
- Android dispatchTouchEvent touch事件的分发
- iOS开发系列--通知与消息机制--转