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

Elasticsearch学习笔记(一)

时间:2016-05-25 18:44:39      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:

批量建索引:

curl -s -XPOST ‘localhost:9200/_bulk‘ --data-binary @documents.json

 

分页:

from、size

 

返回版本:

"version": true

 

利用得分限制结果集:

"min_score": 0.75

 

"fields":*  返回所有字段

_source字段:

请求一个没有存储的字段时,这个字段将从_source字段中提取(需要额外处理);返回_source字段比返回多个存储字段性能更好

 

部分字段:(排除字段)

"partial_fields": { "partial1": { "include": [‘titl*‘], "exclude": ["chara*"] }}

 

脚本字段:

{"scirpt_fields": {"correctYear": {"script": "doc[‘year‘].value - 1800" }}}   或   "script": "_source.year - 1800"  (更省内存,支持更复杂字段值)

传参数给脚本:"params": {"paramYear": 1800}   然后"script": "_source.year - paramYear" }

 

搜索执行偏好:(控制在哪些分片上执行查询,如:_primary、_primary_first、_shards)

curl -XGET ‘localhost:9200/library/_search?preference=_local‘ -d json

 

搜索分片API:(此API允许检查将执行查询的分片)

curl -XGET ‘localhost:9200/library/_search_shards?pretty‘ -d json

 

加权查询:

"title": {"value": "crime", "boost": 10.0}

 

多词条查询:

"terms": {"title": [‘book‘, ‘novel‘], "minimum_match": 1

 

term查询不分析,match查询分析,

 

multi_search查询:(多个字段上查询)

Elasticsearch学习笔记(一)

标签:

原文地址:http://www.cnblogs.com/warmingsun/p/5527963.html

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