[elasticsearch笔记] Query DSL [持续更新中]
2019-07-23 17:28
791 查看
note
demo
GET /_search { "query": { "bool": { "must": [ { "match": { "title": "Search" } }, { "match": { "content": "Elasticsearch" } } ], "filter": [ { "term": { "status": "published" } }, { "range": { "publish_date": { "gte": "2015-01-01" } } } ] } } } POST _search { "query": { "bool": { "must": { "term": { "user": "kimchy" } }, "filter": { "term": { "tag": "tech" } }, "must_not": { "range": { "age": { "gte": 10, "lte": 20 } } }, "should": [ { "term": { "tag": "wow" } }, { "term": { "tag": "elasticsearch" } } ], "minimum_should_match": 1, "boost": 1 } } } GET _search { "query": { "bool": { "filter": { "term": { "status": "active" } } } } } GET _search { "query": { "bool": { "must": { "match_all": {} }, "filter": { "term": { "status": "active" } } } } } GET _search { "query": { "constant_score": { "filter": { "term": { "status": "active" } }, "boost": 1.2 } } } GET /_search { "query": { "boosting": { "positive": { "term": { "text": "apple" } }, "negative": { "term": { "text": "pie tart fruit crumble tree" } }, "negative_boost": 0.5 } } } # # 返回匹配至少一个 query 的搜索,多个匹配时,使用最高的score # GET /_search { "query": { "dis_max": { "queries": [ { "term": { "title": "Quick pets" } }, { "term": { "body": "Quick pets" } } ], "tie_breaker": 0.7 } } } GET /_search { "query": { "function_score": { "query": { "match_all": {} }, "boost": "5", "random_score": {}, "boost_mode": "multiply" } } } GET /_search { "query": { "function_score": { "query": { "match_all": {} }, "boost": "5", "functions": [ { "filter": { "match": { "test": "bar" } }, "random_score": {}, "weight": 23 }, { "filter": { "match": { "test": "cat" } }, "weight": 42 } ], "max_boost": 42, "score_mode": "max", "boost_mode": "multiply", "min_score": 42 } } } GET /_search { "query": { "function_score": { "query": { "match": { "message": "elasticsearch" } }, "script_score": { "script": { "source": "Math.log(2 + doc['likes'].value)" } } } } } GET /_search { "query": { "function_score": { "query": { "match": { "message": "elasticsearch" } }, "script_score": { "script": { "params": { "a": 5, "b": 1.2 }, "source": "params.a / Math.pow(params.b, doc['likes'].value)" } } } } } GET /_search { "query": { "function_score": { "random_score": { "seed": 10, "field": "_seq_no" } } } } GET /_search { "query": { "function_score": { "field_value_factor": { "field": "likes", "factor": 1.2, "modifier": "sqrt", "missing": 1 } } } }
相关文章推荐
- [elasticsearch笔记] Query DSL Term - exists/must_not/fuzzy/ids/prefix/range/regexp/term/terms/wildcard
- [elasticsearch笔记] Query DSL-intervals
- [elasticsearch笔记] Query DSL - span
- [elasticsearch笔记] Query DSL - percolate
- [elasticsearch笔记] Query DSL- distance_feature/more_like_this/rank_feature/script/wrapper query
- 《tomcate权威指南》笔记(持续更新……)
- Elasticsearch DSL中Query与Filter的不同
- (转载)cocos2d-x学习笔记(持续更新)
- 虚拟机centos笔记整理,持续更新~~
- ThinkPHP5学习笔记【持续更新……】
- 【CS229 Lecture notes,Machine Learning,Andrew Ng 】阅读笔记(持续更新中...)
- cocos2d-js游戏设计常用函数笔记(持续更新) (2014-08-18 15:43:12)
- js学习资料笔记合集,持续学习更新中,欢迎大牛们指点
- amlogic平台笔记----持续更新
- Canvas 笔记(持续更新中)
- rxjava操作符笔记及爬坑总结(持续更新中...)
- android使用笔记 持续更新中。。。
- [Java]初学笔记(持续更新)
- spring学习笔记(持续更新)
- 剑指Offer参考答案解析笔记(持续更新)