Skip to content

Commit 3401b21

Browse files
veatchJason Veatch
authored andcommitted
Updated example queries for ES v5
1 parent cdd1fbf commit 3401b21

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

example/queries.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ def print_hits(results):
4141
doc_type='commits',
4242
body={
4343
'query': {
44-
'filtered': {
45-
'query': {
44+
'bool': {
45+
'must': {
4646
'match': {'description': 'fix'}
4747
},
48-
'filter': {
49-
'not': {
50-
'term': {'files': 'test_elasticsearch'}
51-
}
48+
'must_not': {
49+
'term': {'files': 'test_elasticsearch'}
5250
}
5351
}
5452
}
@@ -62,8 +60,8 @@ def print_hits(results):
6260
doc_type='commits',
6361
body={
6462
'query': {
65-
'filtered': {
66-
'filter': {
63+
'bool': {
64+
'must': {
6765
'term': {
6866
# parent ref is stored as type#id
6967
'_parent': 'repos#elasticsearch-py'
@@ -86,19 +84,11 @@ def print_hits(results):
8684
body={
8785
'size': 0,
8886
'query': {
89-
'filtered': {
90-
'filter': {
91-
'has_parent': {
92-
'type': 'repos',
93-
'query': {
94-
'filtered': {
95-
'filter': {
96-
'term': {
97-
'tags': 'python'
98-
}
99-
}
100-
}
101-
}
87+
'has_parent': {
88+
'parent_type': 'repos',
89+
'query': {
90+
'term': {
91+
'tags': 'python'
10292
}
10393
}
10494
}

0 commit comments

Comments
 (0)