ElasticQuery v3 發布,ElasticSearch 查詢構建器
ElasticQuery v3 發布,該版本改進內容包括:
完全支持 ES 2 DSL
移除對
Filter
& ES 1 的支持盡可能使用 ValueError 替代 Exceptions
100% 測試覆蓋率
ElasticQuery 是用于 ElasticSearch 的簡單查詢構建器。可使用 metod 方法調用和相應的參數來生成查詢、過濾和聚合對象。輸出的 dict/json 可直接傳遞給 ES。
示例代碼:
from elasticsearch import Elasticsearch from elasticquery import ElasticQuery, Filter, Query # Create a query with our ES index details q = ElasticQuery( es=Elasticsearch(), index='mapping_test', doc_type='doc_mapping' ) # Query it! q.query( Query.terms('my_field', ['my', 'terms']) ) # Aggregate it! q.aggregate( Aggregate.sum('my_agg', 'my_field') ) # Print the query, then run on ES and print it's output print q.json(indent=4) print q.get()
來自: http://www.oschina.net//news/70562/elasticquery-v3
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!