首页
视频
资源
登录
原
Elasticsearch 显式Mapping设置与常见参数介绍
4608
人阅读
2020/10/15 16:26
总访问:
2538046
评论:
0
收藏:
0
手机
分类:
云产品
![elasticsearch](https://img.tnblog.net/arcimg/hb/5f1adabe8df94fdb8331eb80e393c4a3.jpeg "elasticsearch") >#Elasticsearch 显式Mapping设置与常见参数介绍 [TOC] 如何显示的定义一个Mapping ------------ ```bash Put movies { "mappings" { //define your mappings here } } ``` 自定义Mapping的一些建议 ------------ >- 可以参考 API 手册,纯手写 - 为了减少输入的工作量,减少出错概率,可以依照以下步骤 - 创建一个临时的 index,写入一些样本数据 - 通过访问 Mapping API 获得该临时文件的动态Mapping定义 - 修改后用,使用该配置创建你的索引 - 删除临时索引 控制当前字段是否被索引 ------------ tn>index -控制当前字段是否被索引。默认为true。如果设置成false,该字段不可被搜索。举例,这里不允许mobile字段被索引。 ```bash PUT users { mappings: { "properties": { "firstName": { "type": "text" }, "lastName": { "type": "text" }, "mobile": { "type": "text", "index": false } } } } ``` index Options ------------ ```bash PUT users { mappings: { "properties": { "firstName": { "type": "text" }, "lastName": { "type": "text" }, "mobile": { "type": "text", "index": false }, "bio": { "type": "text", "index_options": "offsets" } } } } ``` tn> 四种不同级别的 Index Options 配置,可以控制倒排索引记录的内容 | | | | ------------ | ------------ | | docs | 记录 doc id | | freqs | 记录 doc id 和 term frequencies | | positions | 记录 doc id / term frequencies / term position | | offsets | doc id /term frequencies / term posistion / character offects | tn>Text 类型默认记录 postions,其他默认为 docs 需要注意的是:记录内容越多,占用存储空间越大 关于Null_value ------------ tn>当我们需要对Null值实现搜索时我们可以这样做 ```bash PUT users { mappings: { "properties": { "name": { "type": "text" }, "mobile": { "type": "keyword", "null_value": "NULL" } } } } #查询出数据 GET users/_search?q=mobile:NULL ``` tn>只有Keyword类型支持设定 Null_Value Copy_to 设置 ------------ ```bash PUT users { mappings: { "properties": { "firstName": { "type": "text", "copy_to": "fullName" }, "lastName": { "type": "text", "copy_to": "fullName" } } } } #查询 Get users/_search?q=fullName:(Bob He) ``` >- _all 在 7 中被 copy_to 所替代 - 满足一些特定的搜索需要 - copy_to 将字段的数值拷贝到目标字段,实现类似_all的作用 - copy_to 的目标字段(fullName)不出现在_source中 数组类型 ------------ tn>Elasticsearch中不提供专门的数组类型。但是任何字段,都可以包含多个相同类型的数值 ```bash Put users/_doc/1 { "name":"onebird", "iinterests":"reading" } Put users/_doc/2 { "name": "twobirds", "interests":["reading","music"] } ```
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}
尘叶心繁
这一世以无限游戏为使命!
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
.net后台框架
166篇
linux
17篇
linux中cve
1篇
windows中cve
0篇
资源分享
10篇
Win32
3篇
前端
28篇
传说中的c
4篇
Xamarin
9篇
docker
15篇
容器编排
101篇
grpc
4篇
Go
15篇
yaml模板
1篇
理论
2篇
更多
Sqlserver
4篇
云产品
39篇
git
3篇
Unity
1篇
考证
2篇
RabbitMq
23篇
Harbor
1篇
Ansible
8篇
Jenkins
17篇
Vue
1篇
Ids4
18篇
istio
1篇
架构
2篇
网络
7篇
windbg
4篇
AI
18篇
threejs
2篇
人物
1篇
嵌入式
2篇
python
13篇
HuggingFace
8篇
pytorch
9篇
opencv
6篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术