_souce禁用,如何搜索? 指定_souce存储的字段?控制从_source返回部分字段?
来源:互联网 发布:抢票软件演唱会 编辑:程序博客网 时间:2024/06/18 05:16
事实上,_source 字段就是一个储存字段。
在 Elasticsearch 中,单独设置储存字段不是一个好做法。完整的文档已经被保存在 _source 字段中。
通常最好的办法会是使用 _source 参数来过滤你需要的字段。
_source禁用,如何搜索到字段值?
必须设置所有字段:store:true
如果mapping中,对于某个type,设置了 “_source”: {“enabled”: false},那么查询结果中就没有_source字段只能查到文档id。
如果mapping中,field设置了store为true,例如 “age”:{“type”:”integer”,”store”:true},那么就可以在查询时通过指定fields获取到指定的field的数据。
store默认false。
fielddata_fields 和 fields区别?
fielddata_fields同时还返回_source, fields不返回_source。
- field data fields(fielddata_fields) can work on fields that are not stored(from _source),will cause the terms for that field to be loaded to memory (cached),
- fields parameter(fields) is about fields that are explicitly marked as stored in the mapping, which is off by default and generally not recommended.
https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-request-fielddata-fields.html
https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-request-fields.html
REST:
https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-request-fields.html
{ "fields" : ["user", "postDate"], "query" : { "term" : { "user" : "kimchy" } }}
Java API
SearchRequestBuilder类方法:addFields(String... fields)或:addField(String field)
建索引时,指定_souce存储的字段?
默认存储所有字段
PUT logs{ "mappings": { "event": { "_source": { "includes": [ "*.count", "meta.*" ], "excludes": [ "meta.description", "meta.other.*" ] } } }}
控制从_source返回部分字段
GET /_search{ "query": { "match_all": {}}, "_source": [ "title", "created" ]}//支持通配符{ "_source": "obj.*", "query" : { "term" : { "user" : "kimchy" } }}{ "_source": [ "obj1.*", "obj2.*" ], "query" : { "term" : { "user" : "kimchy" } }}{ "_source": { "include": [ "obj1.*", "obj2.*" ], "exclude": [ "*.description" ] }, "query" : { "term" : { "user" : "kimchy" } }}
PUT demo{ "mappings": { "mytype": { "_source": { "enabled": false }, "_all": { "enabled": false }, "properties": { "store": { "store": true, "type": "long" }, "nostore": { "type": "long" }, "date": { "type": "date" } } } }}POST demo/mytype{ "store":11, "nostore":12, "date":"2006-12-14"}GET demo/mytype/_search{ "fields":[ "store","nostore","date" ]}GET demo/mytype/_search{ "fielddata_fields":[ "store","nostore","date" ]}
script
Elasticsearch增删改查 之 —— Update更新
批量更新:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
Elasticsearch’s Update_by_query: Update Multiple Documents Simultaneously【ES 2.3】
https://qbox.io/blog/elasticsearch-update_by_query-multiple-documents-simultaneously
Query DSL » Specialized queries » Script Query
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html
- _souce禁用,如何搜索? 指定_souce存储的字段?控制从_source返回部分字段?
- Elasticsearch Fields _source 返回值字段设置
- elasticsearch的store属性跟_source字段
- elasticsearch的store属性跟_source字段
- elasticsearch的store属性跟_source字段
- django model 返回指定的字段
- SQL 搜索指定字段不包含指定值的方法
- spring-mongodb返回指定字段
- elasticsearch 在查询的时候如何返回指定的字段值?
- php中sphinx的Query接口如何指定字段搜索呢?
- Hibernate查询指定字段并返回对象的结果集
- 通过id查询用户,但是只返回指定的字段
- java操作mongodb,返回某个文档的指定字段
- 关于hql语句只返回指定字段的一种写法
- C#中的反射:返回指定类型的字段
- 从文本文件提取数据到数据库指定的字段中
- 在从数据库向程序导入指定字段的方法
- mongodb中查询返回指定字段
- Morris Traversal
- Android openGL ES2.0 Matrix.frustumM和Matrix.setLookAtM解析
- spring容器及bean加载机制源码解读
- HDU2602/HDU1114/HDU2191(重新整理一下01背包,完全背包,多重背包)
- 高精度之高精除以低精取余(天使的起誓)
- _souce禁用,如何搜索? 指定_souce存储的字段?控制从_source返回部分字段?
- Android 截取View,获取View的Bitmap的方法
- 移动端app项目总结
- centos安装samba实现linux文件共享到windows
- Unity Mask遮挡模型忽略UI
- Spring任务调度scheduled
- 字节码转换学习
- mongodb 返回内嵌数组中的一条
- Spark SQL读取Hive数据配置及使用Thrift JDBC/ODBC Server访问Spark SQL