Skip to content
This repository was archived by the owner on Nov 14, 2021. It is now read-only.

Commit 55d9bf8

Browse files
committed
v3.
1 parent 4e285dd commit 55d9bf8

File tree

3 files changed

+13
-48
lines changed

3 files changed

+13
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# v3 (WIP)
1+
# v3
22

33
+ Full ES 2 DSL support
44
+ Removed `Filter` & ES 1 support

README.md

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# ElasticQuery v3 (WIP) [![PyPI version](https://badge.fury.io/py/ElasticQuery.svg)](https://pypi.python.org/pypi/ElasticQuery)
1+
# ElasticQuery v3 [![PyPI version](https://badge.fury.io/py/ElasticQuery.svg)](https://pypi.python.org/pypi/ElasticQuery)
22

33
A simple query builder for Elasticsearch. Install with `pip install elasticquery`. Uses metod calls and their args/kwargs to generate query/filter/aggregate objects. Outputs dict/json represntation to be passed directly to ES.
44

5-
### API
6-
7-
+ [ElasticQuery](https://elasticquery.readthedocs.org/client.html)
8-
+ [Queries](https://elasticquery.readthedocs.org/queries.html)
9-
+ [Aggregates](https://elasticquery.readthedocs.org/aggregates.html)
10-
+ [Suggesters](https://elasticquery.readthedocs.org/suggesters.html)
11-
+ [Filters](https://elasticquery.readthedocs.org/filters.html)
5+
+ [Documentation](https://elasticquery.readthedocs.org/en/latest/)
6+
+ [Queries API](https://elasticquery.readthedocs.org/en/latest/queries.html)
7+
+ [Aggregates API](https://elasticquery.readthedocs.org/en/latest/aggregates.html)
8+
+ [Suggesters API](https://elasticquery.readthedocs.org/en/latest/suggesters.html)
129

1310

1411
## Synopsis
@@ -18,44 +15,21 @@ from elasticsearch import Elasticsearch
1815
from elasticquery import ElasticQuery, Filter, Query
1916

2017

18+
# Create a query with our ES index details
2119
q = ElasticQuery(
2220
es=Elasticsearch(),
2321
index='mapping_test',
2422
doc_type='doc_mapping'
2523
)
2624

27-
# -> query.filtered.filter
28-
q.filter(
29-
# -> query.filtered.filter.bool
30-
Filter.bool(must=[
31-
# -> query.filtered.filter.bool.must.terms
32-
Filter.terms('field', ['this', 'that'])
33-
], must_not=[
34-
# -> query.filtered.filter.bool.must_not.or
35-
Filter.or_(
36-
# -> query.filtered.filter.bool.must_not.or.term
37-
Filter.term('another_field', 'matching-term'),
38-
# -> query.filtered.filter.bool.must_not.or.query.query_string
39-
Filter.query(
40-
Query.query_string('A QUERY STRING', default_operator='OR')
41-
)
42-
)
43-
])
44-
)
45-
46-
# -> query.filtered.query
25+
# Query it!
4726
q.query(
48-
# -> query.filtered.query.prefix
49-
Query.prefix('field', 'prefixed-')
27+
Query.terms('my_field', ['my', 'terms'])
5028
)
5129

52-
# -> aggregates
30+
# Aggregate it!
5331
q.aggregate(
54-
# -> aggregates.agg_name
55-
Aggregate.date_histogram('agg_name', 'date_field', '1d').aggregate(
56-
# aggregates.agg_name.aggregates.sub_agg_name
57-
Aggregate.terms('sub_agg_name', 'terms_field', size=50)
58-
)
32+
Aggregate.sum('my_agg', 'my_field')
5933
)
6034

6135
# Print the query, then run on ES and print it's output
@@ -64,16 +38,7 @@ print q.get()
6438
```
6539

6640

67-
## Naming Differences
68-
69-
ElasticQuery attempts to keep all names and arguments in-line with their ES coutnerparts. Unfortunately a number of key terms are reserved by Python, so ElasticQuery implements the following alternatives:
70-
71-
+ `from` -> `from_` (eg setting query['from'])
72-
+ `or` -> `or_` (eg or_filters)
73-
+ `and` -> `and_` (eg and_filters)
74-
75-
76-
## Testing
41+
## Development/Testing
7742

7843
+ Create virtualenv
7944
+ `pip install requirements.pip`

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
if __name__ == '__main__':
99
setup(
10-
version='3.dev0',
10+
version='3',
1111
name='ElasticQuery',
1212
description='A simple query builder for Elasticsearch 2',
1313
author='Nick Barrett',

0 commit comments

Comments
 (0)