Skip to content

Commit b78cfbf

Browse files
rciorbahonzakral
authored andcommitted
Add query_string parameters to count, search_exists and validate_query
1 parent 024d5df commit b78cfbf

File tree

2 files changed

+60
-23
lines changed

2 files changed

+60
-23
lines changed

elasticsearch/client/__init__.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,10 @@ def delete(self, index, doc_type, id, params=None):
670670
_, data = self.transport.perform_request('DELETE', _make_path(index, doc_type, id), params=params)
671671
return data
672672

673-
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
674-
'min_score', 'preference', 'q', 'routing')
673+
@query_params('allow_no_indices', 'analyze_wildcard', 'analyzer',
674+
'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable',
675+
'min_score', 'lenient', 'lowercase_expanded_terms', 'min_score',
676+
'preference', 'q', 'routing')
675677
def count(self, index=None, doc_type=None, body=None, params=None):
676678
"""
677679
Execute a query and get the number of matches for that query.
@@ -683,11 +685,24 @@ def count(self, index=None, doc_type=None, body=None, params=None):
683685
:arg allow_no_indices: Whether to ignore if a wildcard indices
684686
expression resolves into no concrete indices. (This includes `_all`
685687
string or when no indices have been specified)
688+
:arg analyze_wildcard: Specify whether wildcard and prefix queries
689+
should be analyzed (default: false)
690+
:arg analyzer: The analyzer to use for the query string
691+
:arg default_operator: The default operator for query string query (AND
692+
or OR), default u'OR'
693+
:arg df: The field to use as default where no field prefix is given in
694+
the query string
686695
:arg expand_wildcards: Whether to expand wildcard expression to concrete
687696
indices that are open, closed or both., default 'open'
688697
:arg ignore_unavailable: Whether specified concrete indices should be
689698
ignored when unavailable (missing or closed)
690699
:arg min_score: Include only documents with a specific `_score` value in the result
700+
:arg lenient: Specify whether format-based query failures (such as
701+
providing text to a numeric field) should be ignored
702+
:arg lowercase_expanded_terms: Specify whether query terms should be
703+
lowercased
704+
:arg min_score: Include only documents with a specific `_score` value in
705+
the result
691706
:arg preference: Specify the node or shard the operation should be
692707
performed on (default: random)
693708
:arg q: Query in the Lucene query string syntax
@@ -746,7 +761,7 @@ def msearch(self, body, index=None, doc_type=None, params=None):
746761

747762
@query_params('allow_no_indices', 'analyzer', 'consistency',
748763
'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable', 'q',
749-
'routing', 'source', 'timeout')
764+
'routing', 'timeout')
750765
def delete_by_query(self, index, doc_type=None, body=None, params=None):
751766
"""
752767
Delete documents from one or more indices and one or more types based on a query.
@@ -772,8 +787,6 @@ def delete_by_query(self, index, doc_type=None, body=None, params=None):
772787
ignored when unavailable (missing or closed)
773788
:arg q: Query in the Lucene query string syntax
774789
:arg routing: Specific routing value
775-
:arg source: The URL-encoded query definition (instead of using the
776-
request body)
777790
:arg timeout: Explicit operation timeout
778791
"""
779792
if index in SKIP_IN_PATH:
@@ -1192,8 +1205,10 @@ def delete_template(self, id=None, params=None):
11921205
'template', id), params=params)
11931206
return data
11941207

1195-
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
1196-
'min_score', 'preference', 'routing', 'source')
1208+
@query_params('allow_no_indices', 'analyze_wildcard', 'analyzer',
1209+
'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable',
1210+
'lenient', 'lowercase_expanded_terms', 'min_score', 'preference', 'q',
1211+
'routing')
11971212
def search_exists(self, index=None, doc_type=None, body=None, params=None):
11981213
"""
11991214
The exists API allows to easily determine if any matching documents
@@ -1207,17 +1222,27 @@ def search_exists(self, index=None, doc_type=None, body=None, params=None):
12071222
:arg allow_no_indices: Whether to ignore if a wildcard indices
12081223
expression resolves into no concrete indices. (This includes `_all`
12091224
string or when no indices have been specified)
1225+
:arg analyze_wildcard: Specify whether wildcard and prefix queries
1226+
should be analyzed (default: false)
1227+
:arg analyzer: The analyzer to use for the query string
1228+
:arg default_operator: The default operator for query string query (AND
1229+
or OR), default u'OR'
1230+
:arg df: The field to use as default where no field prefix is given in
1231+
the query string
12101232
:arg expand_wildcards: Whether to expand wildcard expression to concrete
12111233
indices that are open, closed or both., default u'open'
12121234
:arg ignore_unavailable: Whether specified concrete indices should be
12131235
ignored when unavailable (missing or closed)
1236+
:arg lenient: Specify whether format-based query failures (such as
1237+
providing text to a numeric field) should be ignored
1238+
:arg lowercase_expanded_terms: Specify whether query terms should be
1239+
lowercased
12141240
:arg min_score: Include only documents with a specific `_score` value in
12151241
the result
12161242
:arg preference: Specify the node or shard the operation should be
12171243
performed on (default: random)
1244+
:arg q: Query in the Lucene query string syntax
12181245
:arg routing: Specific routing value
1219-
:arg source: The URL-encoded query definition (instead of using the
1220-
request body)
12211246
"""
12221247
_, data = self.transport.perform_request('POST', _make_path(index,
12231248
doc_type, '_search', 'exists'), params=params, body=body)

elasticsearch/client/indices.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -809,28 +809,40 @@ def optimize(self, index=None, params=None):
809809
_, data = self.transport.perform_request('POST', _make_path(index, '_optimize'), params=params)
810810
return data
811811

812-
@query_params('explain', 'allow_no_indices', 'expand_wildcards',
813-
'ignore_indices', 'ignore_unavailable', 'operation_threading', 'q')
812+
@query_params('allow_no_indices', 'analyze_wildcard', 'analyzer',
813+
'default_operator', 'df', 'expand_wildcards', 'explain',
814+
'ignore_unavailable', 'lenient', 'lowercase_expanded_terms',
815+
'operation_threading', 'q')
814816
def validate_query(self, index=None, doc_type=None, body=None, params=None):
815817
"""
816818
Validate a potentially expensive query without executing it.
817819
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-validate.html>`_
818820
819-
:arg index: A comma-separated list of index names to restrict the operation;
820-
use `_all` or empty string to perform the operation on all indices
821+
:arg index: A comma-separated list of index names to restrict the
822+
operation; use `_all` or empty string to perform the operation on
823+
all indices
821824
:arg doc_type: A comma-separated list of document types to restrict the
822825
operation; leave empty to perform the operation on all types
823-
:arg body: The query definition
824-
:arg explain: Return detailed information about the error
826+
:arg body: The query definition specified with the Query DSL
825827
:arg allow_no_indices: Whether to ignore if a wildcard indices
826-
expression resolves into no concrete indices. (This includes `_all` string or
827-
when no indices have been specified)
828-
:arg expand_wildcards: Whether to expand wildcard expression to concrete indices
829-
that are open, closed or both.
830-
:arg ignore_indices: When performed on multiple indices, allows to
831-
ignore `missing` ones (default: none)
832-
:arg ignore_unavailable: Whether specified concrete indices should be ignored
833-
when unavailable (missing or closed)
828+
expression resolves into no concrete indices. (This includes `_all`
829+
string or when no indices have been specified)
830+
:arg analyze_wildcard: Specify whether wildcard and prefix queries
831+
should be analyzed (default: false)
832+
:arg analyzer: The analyzer to use for the query string
833+
:arg default_operator: The default operator for query string query (AND
834+
or OR), default u'OR'
835+
:arg df: The field to use as default where no field prefix is given in
836+
the query string
837+
:arg expand_wildcards: Whether to expand wildcard expression to concrete
838+
indices that are open, closed or both., default u'open'
839+
:arg explain: Return detailed information about the error
840+
:arg ignore_unavailable: Whether specified concrete indices should be
841+
ignored when unavailable (missing or closed)
842+
:arg lenient: Specify whether format-based query failures (such as
843+
providing text to a numeric field) should be ignored
844+
:arg lowercase_expanded_terms: Specify whether query terms should be
845+
lowercased
834846
:arg operation_threading: TODO: ?
835847
:arg q: Query in the Lucene query string syntax
836848
"""

0 commit comments

Comments
 (0)