45.mapping建立、修改
主要知识点
1、如何建立索引
2、修改mapping
3、测试mapping
一、如何建立索引
语法
PUT /website
{
"mappings": {
"article": {
"properties": {
"author_id": {
"type": "long",
"index":"anaalyzed"
},
}
}
analyzed 分词
not_analyzed 不分词
no 不能被索引和搜索
二、修改mapping
只能创建index时手动建立mapping,或者新增field mapping,不能update field mapping(也就是不能修改已创建好的field的mapping)
1、先插入一个index
PUT /website
{
"mappings": {
"article": { #--->type
"properties": {
"author_id": { # ---->field
"type": "long"
},
"title": { # ---->field
"type": "text",
"analyzer": "english"
},
"content": { # ---->field
"type": "text"
},
"post_date": { # ---->field
"type": "date"
},
"publisher_id": { # ---->field
"type": "text",
"index": "not_analyzed"
}
}
}
}
}
2、修改已存在的field的type
PUT /website
{
"mappings": {
"article": {
"properties": {
"author_id": {
"type": "text"
}
}
}
}
}
执行结果是:
{
"error": {
"root_cause": [
{
"type": "index_already_exists_exception",
"reason": "index [website/co1dgJ-uTYGBEEOOL8GsQQ] already exists",
"index_uuid": "co1dgJ-uTYGBEEOOL8GsQQ",
"index": "website"
}
],
"type": "index_already_exists_exception",
"reason": "index [website/co1dgJ-uTYGBEEOOL8GsQQ] already exists",
"index_uuid": "co1dgJ-uTYGBEEOOL8GsQQ",
"index": "website"
},
"status": 400
}
3、插入新的field,并指定mapping
PUT /website/_mapping/article
{
"properties" : {
"new_field" : {
"type" : "string",
"index": "not_analyzed"
}
}
}
三、测试mapping
1、测试可分词
GET /website/_analyze
{
"field": "content",
"text": "my-dogs"
}
2、测试不可分词
GET website/_analyze
{
"field": "new_field",
"text": "my dogs"
}
执行结果是:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[4onsTYV][127.0.0.1:9300][indices:admin/analyze[s]]"
}
],
"type": "illegal_argument_exception",
"reason": "Can't process field [new_field], Analysis requests are only supported on tokenized fields"
},
"status": 400
}
45.mapping建立、修改的更多相关文章
- Elasticsearch 的坑爹事——记录一次mapping field修改过程
Elasticsearch 的坑爹事 本文记录一次Elasticsearch mapping field修改过程 团队使用Elasticsearch做日志的分类检索分析服务,使用了类似如下的_mapp ...
- Elasticsearch 的坑爹事——记录一次mapping field修改过程(转)
原文:http://www.cnblogs.com/Creator/p/3722408.html 本文记录一次Elasticsearch mapping field修改过程 团队使用Elasticse ...
- (转)Elasticsearch 的坑爹事——记录一次mapping field修改过程
Elasticsearch 的坑爹事 本文记录一次Elasticsearch mapping field修改过程 团队使用Elasticsearch做日志的分类检索分析服务,使用了类似如下的_mapp ...
- ES mapping field修改过程
Elasticsearch 的坑爹事--记录一次mapping field修改过程 http://www.cnblogs.com/Creator/p/3722408.html Elasticsearc ...
- ar - 建立, 修改档案或从档案中抽取成员.
总览 ar [-]{dmpqrtx}[abcfilNoPsSuvV] [membername] [count] archive files... 描述 GNU 组织的ar 程序 用于建立, 修改档案 ...
- ES mapping可以修改include_in_all,也可以修改index_options,norm,但是无法修改_all属性!
ES mapping可以修改include_in_all,也可以修改index_options,norm,但是无法修改_all属性! curl -XPOST "http://localhos ...
- 建立&修改视图
一.建立视图 IF OBJECT_ID('Sales.OrderTotalsByYear', 'V') IS NOT NULL DROP VIEW Sales.OrderTotalsByYear; G ...
- Elasticsearch索引mapping的写入、查看与修改(转)
mapping的写入与查看 首先创建一个索引: curl -XPOST "http://127.0.0.1:9200/productindex" {"acknowledg ...
- (转)Elasticsearch索引mapping的写入、查看与修改
mapping的写入与查看 首先创建一个索引: curl -XPOST "http://127.0.0.1:9200/productindex" {"acknowledg ...
随机推荐
- 读书笔记-HBase in Action-第一部分 HBase fundamentals
新项目准备上HBase.HBase眼下由组里某牛负责.本着学会使用HBase的目标,先阅读下HBase in Action,一共十章组织成三部分,须要学习的内容包含HBase基本实现原理,用法,Sch ...
- JArray获取元素值
MXS&Vincene ─╄OvЁ &0000003 ─╄OvЁ MXS&Vincene MXS&Vincene ─╄OvЁ:今天很残酷,明天更残酷,后天很美好 ...
- 【iOS】代理传值与块代码传值
主线程与子线程常常须要进行数据的传递.不同的类之间,不同的控制器之间都须要. 并且常常须要监听一个动作的完毕.而后才去做对应事件. (代理是一对一的关系). 一.代理传值 代理是一种设计模式. iOS ...
- HDU 2110-Crisis of HDU(母函数)
Crisis of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- 菜鸟nginx源代码剖析数据结构篇(六) 哈希表 ngx_hash_t(上)
菜鸟nginx源代码剖析数据结构篇(六) 哈希表 ngx_hash_t(上) Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog. ...
- 0x6A 网络流初步
CH Round #17-C 这个算是一个技能点吧,不点不会,点了就没什么了.懒得写看书吧书上的1应该是0... 我又回来了太懒了不想翻书还是写写吧 必须边的判定条件:该边流量为0且两端的点在残余网络 ...
- Enter the path to the kernel header files for the 3.18.0-kali1-686-pae kerne vmware tool
安装VMWare Tools出现提示:Enter the path to the kernel header files for the 3.18.0-kali1-686-pae kerne? 201 ...
- android有用代码片段
一. 获取系统版本号: [java] view plaincopy PackageInfo info = this.getPackageManager().getPackageInfo(this.g ...
- bzoj 1503郁闷的出纳员(splay)
1503: [NOI2004]郁闷的出纳员 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 11759 Solved: 4163[Submit][Stat ...
- C#Cookie操作类,删除Cookie,给Cookie赋值
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security ...