码迷,mamicode.com
首页 > 其他好文 > 详细

64.root object的理解

时间:2018-02-26 21:39:29      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:需要   date   ada   ext   class   其他   post   tle   包括   

一、root object的理解

   

就是某个type对应的mapping json,包括properties,metadata_id_source_type),settingsanalyzer),其他settings(比如include_in_all等,下例中加黄色的就是root object)

   

PUT /my_index

{

"mappings": {

"my_type": {

"properties": {}

}

}

}

   

二、properties

   

在poperties中设置typeindexanalyzer

示例

PUT /my_index/_mapping/my_type

{

"properties": {

"title": {

"type": "text"

}

}

}

   

三、_source

这个选项就是保存原始的json对象

优点:

1)查询的时候,直接可以拿到完整的document,不需要先拿document id,再发送一次请求拿document

2partial update基于_source实现

3reindex时,直接基于_source实现,不需要从数据库(或者其他外部存储)查询数据再修改

4)可以基于_source定制返回field

5debug query更容易,因为可以直接看到_source

   

如果不需要上述好处,可以禁用_source,这样就不保存原始的json对象。

   

PUT /my_index/_mapping/my_type2

{

"_source": {"enabled": false}

}

只能是建立索引时就设置,一但建立索引后就不能再更改。

   

四、_all

   

将所有field合并串联在一起,作为一个_all field字符串,建立索引并进行分词。如果在搜索过程中没指定任何field进行搜索时,就是使用_all field在搜索。也可以在新建index时把该选项设置为false

   

PUT /my_index/_mapping/my_type3

{

"_all": {"enabled": false}

}

   

也可以在field级别设置include_in_all field,设置是否要将field的值包含在_all field

示例

PUT /my_index/_mapping/my_type4

{

"properties": {

"my_field": {

"type": "text",

"include_in_all": false

}

}

}

   

5、标识性metadata

   

_index_type_id

64.root object的理解

标签:需要   date   ada   ext   class   其他   post   tle   包括   

原文地址:https://www.cnblogs.com/liuqianli/p/8475988.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!