nwo
stringlengths
10
28
sha
stringlengths
40
40
path
stringlengths
11
97
identifier
stringlengths
1
64
parameters
stringlengths
2
2.24k
return_statement
stringlengths
0
2.17k
docstring
stringlengths
0
5.45k
docstring_summary
stringlengths
0
3.83k
func_begin
int64
1
13.4k
func_end
int64
2
13.4k
function
stringlengths
28
56.4k
url
stringlengths
106
209
project
int64
1
48
executed_lines
list
executed_lines_pc
float64
0
153
missing_lines
list
missing_lines_pc
float64
0
100
covered
bool
2 classes
filecoverage
float64
2.53
100
function_lines
int64
2
1.46k
mccabe
int64
1
253
coverage
float64
0
100
docstring_lines
int64
0
112
function_nodoc
stringlengths
9
56.4k
id
int64
0
29.8k
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Request._clone
(self)
return s
292
299
def _clone(self): s = self.__class__( using=self._using, index=self._index, doc_type=self._doc_type ) s._doc_type_map = self._doc_type_map.copy() s._extra = self._extra.copy() s._params = self._params.copy() return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L292-L299
37
[ 0, 1, 4, 5, 6, 7 ]
75
[]
0
false
82.288828
8
1
100
0
def _clone(self): s = self.__class__( using=self._using, index=self._index, doc_type=self._doc_type ) s._doc_type_map = self._doc_type_map.copy() s._extra = self._extra.copy() s._params = self._params.copy() return s
22,916
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.__init__
(self, **kwargs)
Search request to elasticsearch. :arg using: `Elasticsearch` instance to use :arg index: limit the search to index :arg doc_type: only query this type. All the parameters supplied (or omitted) at creation type can be later overridden by methods (`using`, `index` and `doc_type` respectively).
Search request to elasticsearch.
306
329
def __init__(self, **kwargs): """ Search request to elasticsearch. :arg using: `Elasticsearch` instance to use :arg index: limit the search to index :arg doc_type: only query this type. All the parameters supplied (or omitted) at creation type can be later overridden by methods (`using`, `index` and `doc_type` respectively). """ super().__init__(**kwargs) self.aggs = AggsProxy(self) self._sort = [] self._source = None self._highlight = {} self._highlight_opts = {} self._suggest = {} self._script_fields = {} self._response_class = Response self._query_proxy = QueryProxy(self, "query") self._post_filter_proxy = QueryProxy(self, "post_filter")
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L306-L329
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 ]
100
[]
0
true
82.288828
24
1
100
8
def __init__(self, **kwargs): super().__init__(**kwargs) self.aggs = AggsProxy(self) self._sort = [] self._source = None self._highlight = {} self._highlight_opts = {} self._suggest = {} self._script_fields = {} self._response_class = Response self._query_proxy = QueryProxy(self, "query") self._post_filter_proxy = QueryProxy(self, "post_filter")
22,917
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.filter
(self, *args, **kwargs)
return self.query(Bool(filter=[Q(*args, **kwargs)]))
331
332
def filter(self, *args, **kwargs): return self.query(Bool(filter=[Q(*args, **kwargs)]))
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L331-L332
37
[ 0, 1 ]
100
[]
0
true
82.288828
2
1
100
0
def filter(self, *args, **kwargs): return self.query(Bool(filter=[Q(*args, **kwargs)]))
22,918
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.exclude
(self, *args, **kwargs)
return self.query(Bool(filter=[~Q(*args, **kwargs)]))
334
335
def exclude(self, *args, **kwargs): return self.query(Bool(filter=[~Q(*args, **kwargs)]))
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L334-L335
37
[ 0, 1 ]
100
[]
0
true
82.288828
2
1
100
0
def exclude(self, *args, **kwargs): return self.query(Bool(filter=[~Q(*args, **kwargs)]))
22,919
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.__iter__
(self)
return iter(self.execute())
Iterate over the hits.
Iterate over the hits.
337
341
def __iter__(self): """ Iterate over the hits. """ return iter(self.execute())
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L337-L341
37
[ 0, 1, 2, 3, 4 ]
100
[]
0
true
82.288828
5
1
100
1
def __iter__(self): return iter(self.execute())
22,920
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.__getitem__
(self, n)
Support slicing the `Search` instance for pagination. Slicing equates to the from/size parameters. E.g.:: s = Search().query(...)[0:25] is equivalent to:: s = Search().query(...).extra(from_=0, size=25)
Support slicing the `Search` instance for pagination.
343
375
def __getitem__(self, n): """ Support slicing the `Search` instance for pagination. Slicing equates to the from/size parameters. E.g.:: s = Search().query(...)[0:25] is equivalent to:: s = Search().query(...).extra(from_=0, size=25) """ s = self._clone() if isinstance(n, slice): # If negative slicing, abort. if n.start and n.start < 0 or n.stop and n.stop < 0: raise ValueError("Search does not support negative slicing.") # Elasticsearch won't get all results so we default to size: 10 if # stop not given. s._extra["from"] = n.start or 0 s._extra["size"] = max( 0, n.stop - (n.start or 0) if n.stop is not None else 10 ) return s else: # This is an index lookup, equivalent to slicing by [n:n+1]. # If negative index, abort. if n < 0: raise ValueError("Search does not support negative indexing.") s._extra["from"] = n s._extra["size"] = 1 return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L343-L375
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32 ]
90.909091
[ 18, 29 ]
6.060606
false
82.288828
33
9
93.939394
9
def __getitem__(self, n): s = self._clone() if isinstance(n, slice): # If negative slicing, abort. if n.start and n.start < 0 or n.stop and n.stop < 0: raise ValueError("Search does not support negative slicing.") # Elasticsearch won't get all results so we default to size: 10 if # stop not given. s._extra["from"] = n.start or 0 s._extra["size"] = max( 0, n.stop - (n.start or 0) if n.stop is not None else 10 ) return s else: # This is an index lookup, equivalent to slicing by [n:n+1]. # If negative index, abort. if n < 0: raise ValueError("Search does not support negative indexing.") s._extra["from"] = n s._extra["size"] = 1 return s
22,921
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.from_dict
(cls, d)
return s
Construct a new `Search` instance from a raw dict containing the search body. Useful when migrating from raw dictionaries. Example:: s = Search.from_dict({ "query": { "bool": { "must": [...] } }, "aggs": {...} }) s = s.filter('term', published=True)
Construct a new `Search` instance from a raw dict containing the search body. Useful when migrating from raw dictionaries.
378
397
def from_dict(cls, d): """ Construct a new `Search` instance from a raw dict containing the search body. Useful when migrating from raw dictionaries. Example:: s = Search.from_dict({ "query": { "bool": { "must": [...] } }, "aggs": {...} }) s = s.filter('term', published=True) """ s = cls() s.update_from_dict(d) return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L378-L397
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ]
100
[]
0
true
82.288828
20
1
100
14
def from_dict(cls, d): s = cls() s.update_from_dict(d) return s
22,922
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search._clone
(self)
return s
Return a clone of the current search request. Performs a shallow copy of all the underlying objects. Used internally by most state modifying APIs.
Return a clone of the current search request. Performs a shallow copy of all the underlying objects. Used internally by most state modifying APIs.
399
420
def _clone(self): """ Return a clone of the current search request. Performs a shallow copy of all the underlying objects. Used internally by most state modifying APIs. """ s = super()._clone() s._response_class = self._response_class s._sort = self._sort[:] s._source = copy.copy(self._source) if self._source is not None else None s._highlight = self._highlight.copy() s._highlight_opts = self._highlight_opts.copy() s._suggest = self._suggest.copy() s._script_fields = self._script_fields.copy() for x in ("query", "post_filter"): getattr(s, x)._proxied = getattr(self, x)._proxied # copy top-level bucket definitions if self.aggs._params.get("aggs"): s.aggs._params = {"aggs": self.aggs._params["aggs"].copy()} return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L399-L420
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 ]
100
[]
0
true
82.288828
22
3
100
3
def _clone(self): s = super()._clone() s._response_class = self._response_class s._sort = self._sort[:] s._source = copy.copy(self._source) if self._source is not None else None s._highlight = self._highlight.copy() s._highlight_opts = self._highlight_opts.copy() s._suggest = self._suggest.copy() s._script_fields = self._script_fields.copy() for x in ("query", "post_filter"): getattr(s, x)._proxied = getattr(self, x)._proxied # copy top-level bucket definitions if self.aggs._params.get("aggs"): s.aggs._params = {"aggs": self.aggs._params["aggs"].copy()} return s
22,923
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.response_class
(self, cls)
return s
Override the default wrapper used for the response.
Override the default wrapper used for the response.
422
428
def response_class(self, cls): """ Override the default wrapper used for the response. """ s = self._clone() s._response_class = cls return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L422-L428
37
[ 0, 1, 2, 3, 4, 5, 6 ]
100
[]
0
true
82.288828
7
1
100
1
def response_class(self, cls): s = self._clone() s._response_class = cls return s
22,924
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.update_from_dict
(self, d)
return self
Apply options from a serialized body to the current instance. Modifies the object in-place. Used mostly by ``from_dict``.
Apply options from a serialized body to the current instance. Modifies the object in-place. Used mostly by ``from_dict``.
430
463
def update_from_dict(self, d): """ Apply options from a serialized body to the current instance. Modifies the object in-place. Used mostly by ``from_dict``. """ d = d.copy() if "query" in d: self.query._proxied = Q(d.pop("query")) if "post_filter" in d: self.post_filter._proxied = Q(d.pop("post_filter")) aggs = d.pop("aggs", d.pop("aggregations", {})) if aggs: self.aggs._params = { "aggs": {name: A(value) for (name, value) in aggs.items()} } if "sort" in d: self._sort = d.pop("sort") if "_source" in d: self._source = d.pop("_source") if "highlight" in d: high = d.pop("highlight").copy() self._highlight = high.pop("fields") self._highlight_opts = high if "suggest" in d: self._suggest = d.pop("suggest") if "text" in self._suggest: text = self._suggest.pop("text") for s in self._suggest.values(): s.setdefault("text", text) if "script_fields" in d: self._script_fields = d.pop("script_fields") self._extra.update(d) return self
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L430-L463
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 ]
100
[]
0
true
82.288828
34
11
100
2
def update_from_dict(self, d): d = d.copy() if "query" in d: self.query._proxied = Q(d.pop("query")) if "post_filter" in d: self.post_filter._proxied = Q(d.pop("post_filter")) aggs = d.pop("aggs", d.pop("aggregations", {})) if aggs: self.aggs._params = { "aggs": {name: A(value) for (name, value) in aggs.items()} } if "sort" in d: self._sort = d.pop("sort") if "_source" in d: self._source = d.pop("_source") if "highlight" in d: high = d.pop("highlight").copy() self._highlight = high.pop("fields") self._highlight_opts = high if "suggest" in d: self._suggest = d.pop("suggest") if "text" in self._suggest: text = self._suggest.pop("text") for s in self._suggest.values(): s.setdefault("text", text) if "script_fields" in d: self._script_fields = d.pop("script_fields") self._extra.update(d) return self
22,925
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.script_fields
(self, **kwargs)
return s
Define script fields to be calculated on hits. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html for more details. Example:: s = Search() s = s.script_fields(times_two="doc['field'].value * 2") s = s.script_fields( times_three={ 'script': { 'lang': 'painless', 'source': "doc['field'].value * params.n", 'params': {'n': 3} } } )
Define script fields to be calculated on hits. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html for more details.
465
491
def script_fields(self, **kwargs): """ Define script fields to be calculated on hits. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html for more details. Example:: s = Search() s = s.script_fields(times_two="doc['field'].value * 2") s = s.script_fields( times_three={ 'script': { 'lang': 'painless', 'source': "doc['field'].value * params.n", 'params': {'n': 3} } } ) """ s = self._clone() for name in kwargs: if isinstance(kwargs[name], str): kwargs[name] = {"script": kwargs[name]} s._script_fields.update(kwargs) return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L465-L491
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ]
100
[]
0
true
82.288828
27
3
100
17
def script_fields(self, **kwargs): s = self._clone() for name in kwargs: if isinstance(kwargs[name], str): kwargs[name] = {"script": kwargs[name]} s._script_fields.update(kwargs) return s
22,926
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.source
(self, fields=None, **kwargs)
return s
Selectively control how the _source field is returned. :arg fields: wildcard string, array of wildcards, or dictionary of includes and excludes If ``fields`` is None, the entire document will be returned for each hit. If fields is a dictionary with keys of 'includes' and/or 'excludes' the fields will be either included or excluded appropriately. Calling this multiple times with the same named parameter will override the previous values with the new ones. Example:: s = Search() s = s.source(includes=['obj1.*'], excludes=["*.description"]) s = Search() s = s.source(includes=['obj1.*']).source(excludes=["*.description"])
Selectively control how the _source field is returned.
493
536
def source(self, fields=None, **kwargs): """ Selectively control how the _source field is returned. :arg fields: wildcard string, array of wildcards, or dictionary of includes and excludes If ``fields`` is None, the entire document will be returned for each hit. If fields is a dictionary with keys of 'includes' and/or 'excludes' the fields will be either included or excluded appropriately. Calling this multiple times with the same named parameter will override the previous values with the new ones. Example:: s = Search() s = s.source(includes=['obj1.*'], excludes=["*.description"]) s = Search() s = s.source(includes=['obj1.*']).source(excludes=["*.description"]) """ s = self._clone() if fields and kwargs: raise ValueError("You cannot specify fields and kwargs at the same time.") if fields is not None: s._source = fields return s if kwargs and not isinstance(s._source, dict): s._source = {} for key, value in kwargs.items(): if value is None: try: del s._source[key] except KeyError: pass else: s._source[key] = value return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L493-L536
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43 ]
97.727273
[ 25 ]
2.272727
false
82.288828
44
9
97.727273
18
def source(self, fields=None, **kwargs): s = self._clone() if fields and kwargs: raise ValueError("You cannot specify fields and kwargs at the same time.") if fields is not None: s._source = fields return s if kwargs and not isinstance(s._source, dict): s._source = {} for key, value in kwargs.items(): if value is None: try: del s._source[key] except KeyError: pass else: s._source[key] = value return s
22,927
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.sort
(self, *keys)
return s
Add sorting information to the search request. If called without arguments it will remove all sort requirements. Otherwise it will replace them. Acceptable arguments are:: 'some.field' '-some.other.field' {'different.field': {'any': 'dict'}} so for example:: s = Search().sort( 'category', '-title', {"price" : {"order" : "asc", "mode" : "avg"}} ) will sort by ``category``, ``title`` (in descending order) and ``price`` in ascending order using the ``avg`` mode. The API returns a copy of the Search object and can thus be chained.
Add sorting information to the search request. If called without arguments it will remove all sort requirements. Otherwise it will replace them. Acceptable arguments are::
538
569
def sort(self, *keys): """ Add sorting information to the search request. If called without arguments it will remove all sort requirements. Otherwise it will replace them. Acceptable arguments are:: 'some.field' '-some.other.field' {'different.field': {'any': 'dict'}} so for example:: s = Search().sort( 'category', '-title', {"price" : {"order" : "asc", "mode" : "avg"}} ) will sort by ``category``, ``title`` (in descending order) and ``price`` in ascending order using the ``avg`` mode. The API returns a copy of the Search object and can thus be chained. """ s = self._clone() s._sort = [] for k in keys: if isinstance(k, str) and k.startswith("-"): if k[1:] == "_score": raise IllegalOperation("Sorting by `-_score` is not allowed.") k = {k[1:]: {"order": "desc"}} s._sort.append(k) return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L538-L569
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ]
100
[]
0
true
82.288828
32
5
100
20
def sort(self, *keys): s = self._clone() s._sort = [] for k in keys: if isinstance(k, str) and k.startswith("-"): if k[1:] == "_score": raise IllegalOperation("Sorting by `-_score` is not allowed.") k = {k[1:]: {"order": "desc"}} s._sort.append(k) return s
22,928
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.highlight_options
(self, **kwargs)
return s
Update the global highlighting options used for this request. For example:: s = Search() s = s.highlight_options(order='score')
Update the global highlighting options used for this request. For example::
571
581
def highlight_options(self, **kwargs): """ Update the global highlighting options used for this request. For example:: s = Search() s = s.highlight_options(order='score') """ s = self._clone() s._highlight_opts.update(kwargs) return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L571-L581
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
100
[]
0
true
82.288828
11
1
100
5
def highlight_options(self, **kwargs): s = self._clone() s._highlight_opts.update(kwargs) return s
22,929
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.highlight
(self, *fields, **kwargs)
return s
Request highlighting of some fields. All keyword arguments passed in will be used as parameters for all the fields in the ``fields`` parameter. Example:: Search().highlight('title', 'body', fragment_size=50) will produce the equivalent of:: { "highlight": { "fields": { "body": {"fragment_size": 50}, "title": {"fragment_size": 50} } } } If you want to have different options for different fields you can call ``highlight`` twice:: Search().highlight('title', fragment_size=50).highlight('body', fragment_size=100) which will produce:: { "highlight": { "fields": { "body": {"fragment_size": 100}, "title": {"fragment_size": 50} } } }
Request highlighting of some fields. All keyword arguments passed in will be used as parameters for all the fields in the ``fields`` parameter. Example::
583
621
def highlight(self, *fields, **kwargs): """ Request highlighting of some fields. All keyword arguments passed in will be used as parameters for all the fields in the ``fields`` parameter. Example:: Search().highlight('title', 'body', fragment_size=50) will produce the equivalent of:: { "highlight": { "fields": { "body": {"fragment_size": 50}, "title": {"fragment_size": 50} } } } If you want to have different options for different fields you can call ``highlight`` twice:: Search().highlight('title', fragment_size=50).highlight('body', fragment_size=100) which will produce:: { "highlight": { "fields": { "body": {"fragment_size": 100}, "title": {"fragment_size": 50} } } } """ s = self._clone() for f in fields: s._highlight[f] = kwargs return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L583-L621
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 ]
100
[]
0
true
82.288828
39
2
100
31
def highlight(self, *fields, **kwargs): s = self._clone() for f in fields: s._highlight[f] = kwargs return s
22,930
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.suggest
(self, name, text, **kwargs)
return s
Add a suggestions request to the search. :arg name: name of the suggestion :arg text: text to suggest on All keyword arguments will be added to the suggestions body. For example:: s = Search() s = s.suggest('suggestion-1', 'Elasticsearch', term={'field': 'body'})
Add a suggestions request to the search.
623
638
def suggest(self, name, text, **kwargs): """ Add a suggestions request to the search. :arg name: name of the suggestion :arg text: text to suggest on All keyword arguments will be added to the suggestions body. For example:: s = Search() s = s.suggest('suggestion-1', 'Elasticsearch', term={'field': 'body'}) """ s = self._clone() s._suggest[name] = {"text": text} s._suggest[name].update(kwargs) return s
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L623-L638
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
100
[]
0
true
82.288828
16
1
100
9
def suggest(self, name, text, **kwargs): s = self._clone() s._suggest[name] = {"text": text} s._suggest[name].update(kwargs) return s
22,931
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.to_dict
(self, count=False, **kwargs)
return d
Serialize the search into the dictionary that will be sent over as the request's body. :arg count: a flag to specify if we are interested in a body for count - no aggregations, no pagination bounds etc. All additional keyword arguments will be included into the dictionary.
Serialize the search into the dictionary that will be sent over as the request's body.
640
682
def to_dict(self, count=False, **kwargs): """ Serialize the search into the dictionary that will be sent over as the request's body. :arg count: a flag to specify if we are interested in a body for count - no aggregations, no pagination bounds etc. All additional keyword arguments will be included into the dictionary. """ d = {} if self.query: d["query"] = self.query.to_dict() # count request doesn't care for sorting and other things if not count: if self.post_filter: d["post_filter"] = self.post_filter.to_dict() if self.aggs.aggs: d.update(self.aggs.to_dict()) if self._sort: d["sort"] = self._sort d.update(recursive_to_dict(self._extra)) if self._source not in (None, {}): d["_source"] = self._source if self._highlight: d["highlight"] = {"fields": self._highlight} d["highlight"].update(self._highlight_opts) if self._suggest: d["suggest"] = self._suggest if self._script_fields: d["script_fields"] = self._script_fields d.update(recursive_to_dict(kwargs)) return d
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L640-L682
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 ]
100
[]
0
true
82.288828
43
10
100
7
def to_dict(self, count=False, **kwargs): d = {} if self.query: d["query"] = self.query.to_dict() # count request doesn't care for sorting and other things if not count: if self.post_filter: d["post_filter"] = self.post_filter.to_dict() if self.aggs.aggs: d.update(self.aggs.to_dict()) if self._sort: d["sort"] = self._sort d.update(recursive_to_dict(self._extra)) if self._source not in (None, {}): d["_source"] = self._source if self._highlight: d["highlight"] = {"fields": self._highlight} d["highlight"].update(self._highlight_opts) if self._suggest: d["suggest"] = self._suggest if self._script_fields: d["script_fields"] = self._script_fields d.update(recursive_to_dict(kwargs)) return d
22,932
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.count
(self)
return es.count(index=self._index, body=d, **self._params)["count"]
Return the number of hits matching the query and filters. Note that only the actual number is returned.
Return the number of hits matching the query and filters. Note that only the actual number is returned.
684
696
def count(self): """ Return the number of hits matching the query and filters. Note that only the actual number is returned. """ if hasattr(self, "_response") and self._response.hits.total.relation == "eq": return self._response.hits.total.value es = get_connection(self._using) d = self.to_dict(count=True) # TODO: failed shards detection return es.count(index=self._index, body=d, **self._params)["count"]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L684-L696
37
[ 0, 1, 2, 3, 4 ]
38.461538
[ 5, 6, 8, 10, 12 ]
38.461538
false
82.288828
13
3
61.538462
2
def count(self): if hasattr(self, "_response") and self._response.hits.total.relation == "eq": return self._response.hits.total.value es = get_connection(self._using) d = self.to_dict(count=True) # TODO: failed shards detection return es.count(index=self._index, body=d, **self._params)["count"]
22,933
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.execute
(self, ignore_cache=False)
return self._response
Execute the search and return an instance of ``Response`` wrapping all the data. :arg ignore_cache: if set to ``True``, consecutive calls will hit ES, while cached result will be ignored. Defaults to `False`
Execute the search and return an instance of ``Response`` wrapping all the data.
698
712
def execute(self, ignore_cache=False): """ Execute the search and return an instance of ``Response`` wrapping all the data. :arg ignore_cache: if set to ``True``, consecutive calls will hit ES, while cached result will be ignored. Defaults to `False` """ if ignore_cache or not hasattr(self, "_response"): es = get_connection(self._using) self._response = self._response_class( self, es.search(index=self._index, body=self.to_dict(), **self._params) ) return self._response
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L698-L712
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]
100
[]
0
true
82.288828
15
3
100
5
def execute(self, ignore_cache=False): if ignore_cache or not hasattr(self, "_response"): es = get_connection(self._using) self._response = self._response_class( self, es.search(index=self._index, body=self.to_dict(), **self._params) ) return self._response
22,934
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.scan
(self)
Turn the search into a scan search and return a generator that will iterate over all the documents matching the query. Use ``params`` method to specify any additional arguments you with to pass to the underlying ``scan`` helper from ``elasticsearch-py`` - https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.scan
Turn the search into a scan search and return a generator that will iterate over all the documents matching the query.
714
727
def scan(self): """ Turn the search into a scan search and return a generator that will iterate over all the documents matching the query. Use ``params`` method to specify any additional arguments you with to pass to the underlying ``scan`` helper from ``elasticsearch-py`` - https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.scan """ es = get_connection(self._using) for hit in scan(es, query=self.to_dict(), index=self._index, **self._params): yield self._get_result(hit)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L714-L727
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
71.428571
[ 10, 12, 13 ]
21.428571
false
82.288828
14
2
78.571429
6
def scan(self): es = get_connection(self._using) for hit in scan(es, query=self.to_dict(), index=self._index, **self._params): yield self._get_result(hit)
22,935
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
Search.delete
(self)
return AttrDict( es.delete_by_query(index=self._index, body=self.to_dict(), **self._params) )
delete() executes the query by delegating to delete_by_query()
delete() executes the query by delegating to delete_by_query()
729
738
def delete(self): """ delete() executes the query by delegating to delete_by_query() """ es = get_connection(self._using) return AttrDict( es.delete_by_query(index=self._index, body=self.to_dict(), **self._params) )
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L729-L738
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
100
[]
0
true
82.288828
10
1
100
1
def delete(self): es = get_connection(self._using) return AttrDict( es.delete_by_query(index=self._index, body=self.to_dict(), **self._params) )
22,936
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
MultiSearch.__init__
(self, **kwargs)
747
749
def __init__(self, **kwargs): super().__init__(**kwargs) self._searches = []
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L747-L749
37
[ 0 ]
33.333333
[ 1, 2 ]
66.666667
false
82.288828
3
1
33.333333
0
def __init__(self, **kwargs): super().__init__(**kwargs) self._searches = []
22,937
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
MultiSearch.__getitem__
(self, key)
return self._searches[key]
751
752
def __getitem__(self, key): return self._searches[key]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L751-L752
37
[ 0 ]
50
[ 1 ]
50
false
82.288828
2
1
50
0
def __getitem__(self, key): return self._searches[key]
22,938
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
MultiSearch.__iter__
(self)
return iter(self._searches)
754
755
def __iter__(self): return iter(self._searches)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L754-L755
37
[ 0 ]
50
[ 1 ]
50
false
82.288828
2
1
50
0
def __iter__(self): return iter(self._searches)
22,939
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
MultiSearch._clone
(self)
return ms
757
760
def _clone(self): ms = super()._clone() ms._searches = self._searches[:] return ms
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L757-L760
37
[ 0 ]
25
[ 1, 2, 3 ]
75
false
82.288828
4
1
25
0
def _clone(self): ms = super()._clone() ms._searches = self._searches[:] return ms
22,940
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
MultiSearch.add
(self, search)
return ms
Adds a new :class:`~elasticsearch_dsl.Search` object to the request:: ms = MultiSearch(index='my-index') ms = ms.add(Search(doc_type=Category).filter('term', category='python')) ms = ms.add(Search(doc_type=Blog))
Adds a new :class:`~elasticsearch_dsl.Search` object to the request::
762
772
def add(self, search): """ Adds a new :class:`~elasticsearch_dsl.Search` object to the request:: ms = MultiSearch(index='my-index') ms = ms.add(Search(doc_type=Category).filter('term', category='python')) ms = ms.add(Search(doc_type=Blog)) """ ms = self._clone() ms._searches.append(search) return ms
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L762-L772
37
[ 0, 1, 2, 3, 4, 5, 6, 7 ]
72.727273
[ 8, 9, 10 ]
27.272727
false
82.288828
11
1
72.727273
5
def add(self, search): ms = self._clone() ms._searches.append(search) return ms
22,941
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
MultiSearch.to_dict
(self)
return out
774
785
def to_dict(self): out = [] for s in self._searches: meta = {} if s._index: meta["index"] = s._index meta.update(s._params) out.append(meta) out.append(s.to_dict()) return out
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L774-L785
37
[ 0 ]
8.333333
[ 1, 2, 3, 4, 5, 6, 8, 9, 11 ]
75
false
82.288828
12
3
25
0
def to_dict(self): out = [] for s in self._searches: meta = {} if s._index: meta["index"] = s._index meta.update(s._params) out.append(meta) out.append(s.to_dict()) return out
22,942
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/search.py
MultiSearch.execute
(self, ignore_cache=False, raise_on_error=True)
return self._response
Execute the multi search request and return a list of search results.
Execute the multi search request and return a list of search results.
787
810
def execute(self, ignore_cache=False, raise_on_error=True): """ Execute the multi search request and return a list of search results. """ if ignore_cache or not hasattr(self, "_response"): es = get_connection(self._using) responses = es.msearch( index=self._index, body=self.to_dict(), **self._params ) out = [] for s, r in zip(self._searches, responses["responses"]): if r.get("error", False): if raise_on_error: raise TransportError("N/A", r["error"]["type"], r["error"]) r = None else: r = Response(s, r) out.append(r) self._response = out return self._response
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L787-L810
37
[ 0, 1, 2, 3 ]
16.666667
[ 4, 5, 7, 11, 12, 13, 14, 15, 16, 18, 19, 21, 23 ]
54.166667
false
82.288828
24
6
45.833333
1
def execute(self, ignore_cache=False, raise_on_error=True): if ignore_cache or not hasattr(self, "_response"): es = get_connection(self._using) responses = es.msearch( index=self._index, body=self.to_dict(), **self._params ) out = [] for s, r in zip(self._searches, responses["responses"]): if r.get("error", False): if raise_on_error: raise TransportError("N/A", r["error"]["type"], r["error"]) r = None else: r = Response(s, r) out.append(r) self._response = out return self._response
22,943
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/serializer.py
AttrJSONSerializer.default
(self, data)
return super().default(data)
24
29
def default(self, data): if isinstance(data, AttrList): return data._l_ if hasattr(data, "to_dict"): return data.to_dict() return super().default(data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/serializer.py#L24-L29
37
[ 0, 1, 2, 3, 4 ]
83.333333
[ 5 ]
16.666667
false
90
6
3
83.333333
0
def default(self, data): if isinstance(data, AttrList): return data._l_ if hasattr(data, "to_dict"): return data.to_dict() return super().default(data)
22,944
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Properties.__init__
(self)
42
43
def __init__(self): super().__init__()
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L42-L43
37
[ 0, 1 ]
100
[]
0
true
72.60274
2
1
100
0
def __init__(self): super().__init__()
22,945
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Properties.__repr__
(self)
return "Properties()"
45
46
def __repr__(self): return "Properties()"
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L45-L46
37
[ 0 ]
50
[ 1 ]
50
false
72.60274
2
1
50
0
def __repr__(self): return "Properties()"
22,946
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Properties.__getitem__
(self, name)
return self.properties[name]
48
49
def __getitem__(self, name): return self.properties[name]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L48-L49
37
[ 0 ]
50
[ 1 ]
50
false
72.60274
2
1
50
0
def __getitem__(self, name): return self.properties[name]
22,947
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Properties.__contains__
(self, name)
return name in self.properties
51
52
def __contains__(self, name): return name in self.properties
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L51-L52
37
[ 0 ]
50
[ 1 ]
50
false
72.60274
2
1
50
0
def __contains__(self, name): return name in self.properties
22,948
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Properties.to_dict
(self)
return super().to_dict()["properties"]
54
55
def to_dict(self): return super().to_dict()["properties"]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L54-L55
37
[ 0, 1 ]
100
[]
0
true
72.60274
2
1
100
0
def to_dict(self): return super().to_dict()["properties"]
22,949
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Properties.field
(self, name, *args, **kwargs)
return self
57
59
def field(self, name, *args, **kwargs): self.properties[name] = construct_field(*args, **kwargs) return self
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L57-L59
37
[ 0, 1, 2 ]
100
[]
0
true
72.60274
3
1
100
0
def field(self, name, *args, **kwargs): self.properties[name] = construct_field(*args, **kwargs) return self
22,950
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Properties._collect_fields
(self)
Iterate over all Field objects within, including multi fields.
Iterate over all Field objects within, including multi fields.
61
70
def _collect_fields(self): """Iterate over all Field objects within, including multi fields.""" for f in self.properties.to_dict().values(): yield f # multi fields if hasattr(f, "fields"): yield from f.fields.to_dict().values() # nested and inner objects if hasattr(f, "_collect_fields"): yield from f._collect_fields()
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L61-L70
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
100
[]
0
true
72.60274
10
4
100
1
def _collect_fields(self): for f in self.properties.to_dict().values(): yield f # multi fields if hasattr(f, "fields"): yield from f.fields.to_dict().values() # nested and inner objects if hasattr(f, "_collect_fields"): yield from f._collect_fields()
22,951
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Properties.update
(self, other_object)
72
83
def update(self, other_object): if not hasattr(other_object, "properties"): # not an inner/nested object, no merge possible return our, other = self.properties, other_object.properties for name in other: if name in our: if hasattr(our[name], "update"): our[name].update(other[name]) continue our[name] = other[name]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L72-L83
37
[ 0 ]
8.333333
[ 1, 3, 5, 6, 7, 8, 9, 10, 11 ]
75
false
72.60274
12
5
25
0
def update(self, other_object): if not hasattr(other_object, "properties"): # not an inner/nested object, no merge possible return our, other = self.properties, other_object.properties for name in other: if name in our: if hasattr(our[name], "update"): our[name].update(other[name]) continue our[name] = other[name]
22,952
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.__init__
(self)
87
89
def __init__(self): self.properties = Properties() self._meta = {}
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L87-L89
37
[ 0, 1, 2 ]
100
[]
0
true
72.60274
3
1
100
0
def __init__(self): self.properties = Properties() self._meta = {}
22,953
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.__repr__
(self)
return "Mapping()"
91
92
def __repr__(self): return "Mapping()"
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L91-L92
37
[ 0 ]
50
[ 1 ]
50
false
72.60274
2
1
50
0
def __repr__(self): return "Mapping()"
22,954
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping._clone
(self)
return m
94
97
def _clone(self): m = Mapping() m.properties._params = self.properties._params.copy() return m
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L94-L97
37
[ 0 ]
25
[ 1, 2, 3 ]
75
false
72.60274
4
1
25
0
def _clone(self): m = Mapping() m.properties._params = self.properties._params.copy() return m
22,955
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.from_es
(cls, index, using="default")
return m
100
103
def from_es(cls, index, using="default"): m = cls() m.update_from_es(index, using) return m
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L100-L103
37
[ 0 ]
25
[ 1, 2, 3 ]
75
false
72.60274
4
1
25
0
def from_es(cls, index, using="default"): m = cls() m.update_from_es(index, using) return m
22,956
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.resolve_nested
(self, field_path)
return nested, field
105
116
def resolve_nested(self, field_path): field = self nested = [] parts = field_path.split(".") for i, step in enumerate(parts): try: field = field[step] except KeyError: return (), None if isinstance(field, Nested): nested.append(".".join(parts[: i + 1])) return nested, field
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L105-L116
37
[ 0, 1, 2, 3, 4, 5, 6, 9, 10, 11 ]
83.333333
[ 7, 8 ]
16.666667
false
72.60274
12
4
83.333333
0
def resolve_nested(self, field_path): field = self nested = [] parts = field_path.split(".") for i, step in enumerate(parts): try: field = field[step] except KeyError: return (), None if isinstance(field, Nested): nested.append(".".join(parts[: i + 1])) return nested, field
22,957
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.resolve_field
(self, field_path)
return field
118
125
def resolve_field(self, field_path): field = self for step in field_path.split("."): try: field = field[step] except KeyError: return return field
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L118-L125
37
[ 0, 1, 2, 3, 4, 7 ]
75
[ 5, 6 ]
25
false
72.60274
8
3
75
0
def resolve_field(self, field_path): field = self for step in field_path.split("."): try: field = field[step] except KeyError: return return field
22,958
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping._collect_analysis
(self)
return analysis
127
153
def _collect_analysis(self): analysis = {} fields = [] if "_all" in self._meta: fields.append(Text(**self._meta["_all"])) for f in chain(fields, self.properties._collect_fields()): for analyzer_name in ( "analyzer", "normalizer", "search_analyzer", "search_quote_analyzer", ): if not hasattr(f, analyzer_name): continue analyzer = getattr(f, analyzer_name) d = analyzer.get_analysis_definition() # empty custom analyzer, probably already defined out of our control if not d: continue # merge the definition # TODO: conflict detection/resolution for key in d: analysis.setdefault(key, {}).update(d[key]) return analysis
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L127-L153
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ]
81.481481
[]
0
false
72.60274
27
7
100
0
def _collect_analysis(self): analysis = {} fields = [] if "_all" in self._meta: fields.append(Text(**self._meta["_all"])) for f in chain(fields, self.properties._collect_fields()): for analyzer_name in ( "analyzer", "normalizer", "search_analyzer", "search_quote_analyzer", ): if not hasattr(f, analyzer_name): continue analyzer = getattr(f, analyzer_name) d = analyzer.get_analysis_definition() # empty custom analyzer, probably already defined out of our control if not d: continue # merge the definition # TODO: conflict detection/resolution for key in d: analysis.setdefault(key, {}).update(d[key]) return analysis
22,959
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.save
(self, index, using="default")
return index.save()
155
160
def save(self, index, using="default"): from .index import Index index = Index(index, using=using) index.mapping(self) return index.save()
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L155-L160
37
[ 0 ]
16.666667
[ 1, 3, 4, 5 ]
66.666667
false
72.60274
6
1
33.333333
0
def save(self, index, using="default"): from .index import Index index = Index(index, using=using) index.mapping(self) return index.save()
22,960
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.update_from_es
(self, index, using="default")
162
166
def update_from_es(self, index, using="default"): es = get_connection(using) raw = es.indices.get_mapping(index=index) _, raw = raw.popitem() self._update_from_dict(raw["mappings"])
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L162-L166
37
[ 0 ]
20
[ 1, 2, 3, 4 ]
80
false
72.60274
5
1
20
0
def update_from_es(self, index, using="default"): es = get_connection(using) raw = es.indices.get_mapping(index=index) _, raw = raw.popitem() self._update_from_dict(raw["mappings"])
22,961
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping._update_from_dict
(self, raw)
168
178
def _update_from_dict(self, raw): for name, definition in raw.get("properties", {}).items(): self.field(name, definition) # metadata like _all etc for name, value in raw.items(): if name != "properties": if isinstance(value, collections.abc.Mapping): self.meta(name, **value) else: self.meta(name, value)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L168-L178
37
[ 0 ]
9.090909
[ 1, 2, 5, 6, 7, 8, 10 ]
63.636364
false
72.60274
11
5
36.363636
0
def _update_from_dict(self, raw): for name, definition in raw.get("properties", {}).items(): self.field(name, definition) # metadata like _all etc for name, value in raw.items(): if name != "properties": if isinstance(value, collections.abc.Mapping): self.meta(name, **value) else: self.meta(name, value)
22,962
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.update
(self, mapping, update_only=False)
180
195
def update(self, mapping, update_only=False): for name in mapping: if update_only and name in self: # nested and inner objects, merge recursively if hasattr(self[name], "update"): # FIXME only merge subfields, not the settings self[name].update(mapping[name], update_only) continue self.field(name, mapping[name]) if update_only: for name in mapping._meta: if name not in self._meta: self._meta[name] = mapping._meta[name] else: self._meta.update(mapping._meta)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L180-L195
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
87.5
[ 15 ]
6.25
false
72.60274
16
8
93.75
0
def update(self, mapping, update_only=False): for name in mapping: if update_only and name in self: # nested and inner objects, merge recursively if hasattr(self[name], "update"): # FIXME only merge subfields, not the settings self[name].update(mapping[name], update_only) continue self.field(name, mapping[name]) if update_only: for name in mapping._meta: if name not in self._meta: self._meta[name] = mapping._meta[name] else: self._meta.update(mapping._meta)
22,963
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.__contains__
(self, name)
return name in self.properties.properties
197
198
def __contains__(self, name): return name in self.properties.properties
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L197-L198
37
[ 0, 1 ]
100
[]
0
true
72.60274
2
1
100
0
def __contains__(self, name): return name in self.properties.properties
22,964
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.__getitem__
(self, name)
return self.properties.properties[name]
200
201
def __getitem__(self, name): return self.properties.properties[name]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L200-L201
37
[ 0, 1 ]
100
[]
0
true
72.60274
2
1
100
0
def __getitem__(self, name): return self.properties.properties[name]
22,965
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.__iter__
(self)
return iter(self.properties.properties)
203
204
def __iter__(self): return iter(self.properties.properties)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L203-L204
37
[ 0, 1 ]
100
[]
0
true
72.60274
2
1
100
0
def __iter__(self): return iter(self.properties.properties)
22,966
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.field
(self, *args, **kwargs)
return self
206
208
def field(self, *args, **kwargs): self.properties.field(*args, **kwargs) return self
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L206-L208
37
[ 0, 1, 2 ]
100
[]
0
true
72.60274
3
1
100
0
def field(self, *args, **kwargs): self.properties.field(*args, **kwargs) return self
22,967
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.meta
(self, name, params=None, **kwargs)
return self
210
218
def meta(self, name, params=None, **kwargs): if not name.startswith("_") and name not in META_FIELDS: name = "_" + name if params and kwargs: raise ValueError("Meta configs cannot have both value and a dictionary.") self._meta[name] = kwargs if params is None else params return self
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L210-L218
37
[ 0, 1, 2, 3, 4, 6, 7, 8 ]
88.888889
[ 5 ]
11.111111
false
72.60274
9
5
88.888889
0
def meta(self, name, params=None, **kwargs): if not name.startswith("_") and name not in META_FIELDS: name = "_" + name if params and kwargs: raise ValueError("Meta configs cannot have both value and a dictionary.") self._meta[name] = kwargs if params is None else params return self
22,968
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/mapping.py
Mapping.to_dict
(self)
return meta
220
231
def to_dict(self): meta = self._meta # hard coded serialization of analyzers in _all if "_all" in meta: meta = meta.copy() _all = meta["_all"] = meta["_all"].copy() for f in ("analyzer", "search_analyzer", "search_quote_analyzer"): if hasattr(_all.get(f, None), "to_dict"): _all[f] = _all[f].to_dict() meta.update(self.properties.to_dict()) return meta
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/mapping.py#L220-L231
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
100
[]
0
true
72.60274
12
4
100
0
def to_dict(self): meta = self._meta # hard coded serialization of analyzers in _all if "_all" in meta: meta = meta.copy() _all = meta["_all"] = meta["_all"].copy() for f in ("analyzer", "search_analyzer", "search_quote_analyzer"): if hasattr(_all.get(f, None), "to_dict"): _all[f] = _all[f].to_dict() meta.update(self.properties.to_dict()) return meta
22,969
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
A
(name_or_agg, filter=None, **params)
return Agg.get_dsl_class(name_or_agg)(**params)
24
67
def A(name_or_agg, filter=None, **params): if filter is not None: if name_or_agg != "filter": raise ValueError( "Aggregation %r doesn't accept positional argument 'filter'." % name_or_agg ) params["filter"] = filter # {"terms": {"field": "tags"}, "aggs": {...}} if isinstance(name_or_agg, collections.abc.Mapping): if params: raise ValueError("A() cannot accept parameters when passing in a dict.") # copy to avoid modifying in-place agg = name_or_agg.copy() # pop out nested aggs aggs = agg.pop("aggs", None) # pop out meta data meta = agg.pop("meta", None) # should be {"terms": {"field": "tags"}} if len(agg) != 1: raise ValueError( 'A() can only accept dict with an aggregation ({"terms": {...}}). ' "Instead it got (%r)" % name_or_agg ) agg_type, params = agg.popitem() if aggs: params = params.copy() params["aggs"] = aggs if meta: params = params.copy() params["meta"] = meta return Agg.get_dsl_class(agg_type)(_expand__to_dot=False, **params) # Terms(...) just return the nested agg elif isinstance(name_or_agg, Agg): if params: raise ValueError( "A() cannot accept parameters when passing in an Agg object." ) return name_or_agg # "terms", field="tags" return Agg.get_dsl_class(name_or_agg)(**params)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L24-L67
37
[ 0, 1, 2, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 40, 41, 42, 43 ]
79.545455
[ 3 ]
2.272727
false
97.379913
44
10
97.727273
0
def A(name_or_agg, filter=None, **params): if filter is not None: if name_or_agg != "filter": raise ValueError( "Aggregation %r doesn't accept positional argument 'filter'." % name_or_agg ) params["filter"] = filter # {"terms": {"field": "tags"}, "aggs": {...}} if isinstance(name_or_agg, collections.abc.Mapping): if params: raise ValueError("A() cannot accept parameters when passing in a dict.") # copy to avoid modifying in-place agg = name_or_agg.copy() # pop out nested aggs aggs = agg.pop("aggs", None) # pop out meta data meta = agg.pop("meta", None) # should be {"terms": {"field": "tags"}} if len(agg) != 1: raise ValueError( 'A() can only accept dict with an aggregation ({"terms": {...}}). ' "Instead it got (%r)" % name_or_agg ) agg_type, params = agg.popitem() if aggs: params = params.copy() params["aggs"] = aggs if meta: params = params.copy() params["meta"] = meta return Agg.get_dsl_class(agg_type)(_expand__to_dot=False, **params) # Terms(...) just return the nested agg elif isinstance(name_or_agg, Agg): if params: raise ValueError( "A() cannot accept parameters when passing in an Agg object." ) return name_or_agg # "terms", field="tags" return Agg.get_dsl_class(name_or_agg)(**params)
22,970
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Agg.__contains__
(self, key)
return False
75
76
def __contains__(self, key): return False
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L75-L76
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def __contains__(self, key): return False
22,971
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Agg.to_dict
(self)
return d
78
82
def to_dict(self): d = super().to_dict() if "meta" in d[self.name]: d["meta"] = d[self.name].pop("meta") return d
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L78-L82
37
[ 0, 1, 2, 3, 4 ]
100
[]
0
true
97.379913
5
2
100
0
def to_dict(self): d = super().to_dict() if "meta" in d[self.name]: d["meta"] = d[self.name].pop("meta") return d
22,972
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Agg.result
(self, search, data)
return AggResponse(self, search, data)
84
85
def result(self, search, data): return AggResponse(self, search, data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L84-L85
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def result(self, search, data): return AggResponse(self, search, data)
22,973
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase.__contains__
(self, key)
return key in self._params.get("aggs", {})
93
94
def __contains__(self, key): return key in self._params.get("aggs", {})
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L93-L94
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def __contains__(self, key): return key in self._params.get("aggs", {})
22,974
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase.__getitem__
(self, agg_name)
return agg
96
106
def __getitem__(self, agg_name): agg = self._params.setdefault("aggs", {})[agg_name] # propagate KeyError # make sure we're not mutating a shared state - whenever accessing a # bucket, return a shallow copy of it to be safe if isinstance(agg, Bucket): agg = A(agg.name, **agg._params) # be sure to store the copy so any modifications to it will affect us self._params["aggs"][agg_name] = agg return agg
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L96-L106
37
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
100
[]
0
true
97.379913
11
2
100
0
def __getitem__(self, agg_name): agg = self._params.setdefault("aggs", {})[agg_name] # propagate KeyError # make sure we're not mutating a shared state - whenever accessing a # bucket, return a shallow copy of it to be safe if isinstance(agg, Bucket): agg = A(agg.name, **agg._params) # be sure to store the copy so any modifications to it will affect us self._params["aggs"][agg_name] = agg return agg
22,975
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase.__setitem__
(self, agg_name, agg)
108
109
def __setitem__(self, agg_name, agg): self.aggs[agg_name] = A(agg)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L108-L109
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def __setitem__(self, agg_name, agg): self.aggs[agg_name] = A(agg)
22,976
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase.__iter__
(self)
return iter(self.aggs)
111
112
def __iter__(self): return iter(self.aggs)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L111-L112
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def __iter__(self): return iter(self.aggs)
22,977
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase._agg
(self, bucket, name, agg_type, *args, **params)
114
122
def _agg(self, bucket, name, agg_type, *args, **params): agg = self[name] = A(agg_type, *args, **params) # For chaining - when creating new buckets return them... if bucket: return agg # otherwise return self._base so we can keep chaining else: return self._base
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L114-L122
37
[ 0, 1, 2, 3, 4, 5, 6, 8 ]
88.888889
[]
0
false
97.379913
9
2
100
0
def _agg(self, bucket, name, agg_type, *args, **params): agg = self[name] = A(agg_type, *args, **params) # For chaining - when creating new buckets return them... if bucket: return agg # otherwise return self._base so we can keep chaining else: return self._base
22,978
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase.metric
(self, name, agg_type, *args, **params)
return self._agg(False, name, agg_type, *args, **params)
124
125
def metric(self, name, agg_type, *args, **params): return self._agg(False, name, agg_type, *args, **params)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L124-L125
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def metric(self, name, agg_type, *args, **params): return self._agg(False, name, agg_type, *args, **params)
22,979
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase.bucket
(self, name, agg_type, *args, **params)
return self._agg(True, name, agg_type, *args, **params)
127
128
def bucket(self, name, agg_type, *args, **params): return self._agg(True, name, agg_type, *args, **params)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L127-L128
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def bucket(self, name, agg_type, *args, **params): return self._agg(True, name, agg_type, *args, **params)
22,980
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase.pipeline
(self, name, agg_type, *args, **params)
return self._agg(False, name, agg_type, *args, **params)
130
131
def pipeline(self, name, agg_type, *args, **params): return self._agg(False, name, agg_type, *args, **params)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L130-L131
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def pipeline(self, name, agg_type, *args, **params): return self._agg(False, name, agg_type, *args, **params)
22,981
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
AggBase.result
(self, search, data)
return BucketData(self, search, data)
133
134
def result(self, search, data): return BucketData(self, search, data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L133-L134
37
[ 0 ]
50
[ 1 ]
50
false
97.379913
2
1
50
0
def result(self, search, data): return BucketData(self, search, data)
22,982
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Bucket.__init__
(self, **params)
138
141
def __init__(self, **params): super().__init__(**params) # remember self for chaining self._base = self
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L138-L141
37
[ 0, 1, 2, 3 ]
100
[]
0
true
97.379913
4
1
100
0
def __init__(self, **params): super().__init__(**params) # remember self for chaining self._base = self
22,983
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Bucket.to_dict
(self)
return d
143
147
def to_dict(self): d = super(AggBase, self).to_dict() if "aggs" in d[self.name]: d["aggs"] = d[self.name].pop("aggs") return d
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L143-L147
37
[ 0, 1, 2, 3, 4 ]
100
[]
0
true
97.379913
5
2
100
0
def to_dict(self): d = super(AggBase, self).to_dict() if "aggs" in d[self.name]: d["aggs"] = d[self.name].pop("aggs") return d
22,984
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Filter.__init__
(self, filter=None, **params)
157
160
def __init__(self, filter=None, **params): if filter is not None: params["filter"] = filter super().__init__(**params)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L157-L160
37
[ 0, 1, 2, 3 ]
100
[]
0
true
97.379913
4
2
100
0
def __init__(self, filter=None, **params): if filter is not None: params["filter"] = filter super().__init__(**params)
22,985
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Filter.to_dict
(self)
return d
162
165
def to_dict(self): d = super().to_dict() d[self.name].update(d[self.name].pop("filter", {})) return d
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L162-L165
37
[ 0, 1, 2, 3 ]
100
[]
0
true
97.379913
4
1
100
0
def to_dict(self): d = super().to_dict() d[self.name].update(d[self.name].pop("filter", {})) return d
22,986
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
DateHistogram.result
(self, search, data)
return FieldBucketData(self, search, data)
192
193
def result(self, search, data): return FieldBucketData(self, search, data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L192-L193
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def result(self, search, data): return FieldBucketData(self, search, data)
22,987
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Histogram.result
(self, search, data)
return FieldBucketData(self, search, data)
227
228
def result(self, search, data): return FieldBucketData(self, search, data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L227-L228
37
[ 0 ]
50
[ 1 ]
50
false
97.379913
2
1
50
0
def result(self, search, data): return FieldBucketData(self, search, data)
22,988
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
RareTerms.result
(self, search, data)
return FieldBucketData(self, search, data)
250
251
def result(self, search, data): return FieldBucketData(self, search, data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L250-L251
37
[ 0 ]
50
[ 1 ]
50
false
97.379913
2
1
50
0
def result(self, search, data): return FieldBucketData(self, search, data)
22,989
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
Terms.result
(self, search, data)
return FieldBucketData(self, search, data)
269
270
def result(self, search, data): return FieldBucketData(self, search, data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L269-L270
37
[ 0, 1 ]
100
[]
0
true
97.379913
2
1
100
0
def result(self, search, data): return FieldBucketData(self, search, data)
22,990
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
VariableWidthHistogram.result
(self, search, data)
return FieldBucketData(self, search, data)
292
293
def result(self, search, data): return FieldBucketData(self, search, data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L292-L293
37
[ 0 ]
50
[ 1 ]
50
false
97.379913
2
1
50
0
def result(self, search, data): return FieldBucketData(self, search, data)
22,991
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/aggs.py
TopHits.result
(self, search, data)
return TopHitsData(self, search, data)
304
305
def result(self, search, data): return TopHitsData(self, search, data)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/aggs.py#L304-L305
37
[ 0 ]
50
[ 1 ]
50
false
97.379913
2
1
50
0
def result(self, search, data): return TopHitsData(self, search, data)
22,992
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
_date_interval_year
(d)
return d.replace( year=d.year + 1, day=(28 if d.month == 2 and d.day == 29 else d.day) )
169
172
def _date_interval_year(d): return d.replace( year=d.year + 1, day=(28 if d.month == 2 and d.day == 29 else d.day) )
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L169-L172
37
[ 0, 1 ]
50
[]
0
false
69.154229
4
2
100
0
def _date_interval_year(d): return d.replace( year=d.year + 1, day=(28 if d.month == 2 and d.day == 29 else d.day) )
22,993
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
_date_interval_month
(d)
return (d + timedelta(days=32)).replace(day=1)
175
176
def _date_interval_month(d): return (d + timedelta(days=32)).replace(day=1)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L175-L176
37
[ 0, 1 ]
100
[]
0
true
69.154229
2
1
100
0
def _date_interval_month(d): return (d + timedelta(days=32)).replace(day=1)
22,994
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
_date_interval_week
(d)
return d + timedelta(days=7)
179
180
def _date_interval_week(d): return d + timedelta(days=7)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L179-L180
37
[ 0, 1 ]
100
[]
0
true
69.154229
2
1
100
0
def _date_interval_week(d): return d + timedelta(days=7)
22,995
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
_date_interval_day
(d)
return d + timedelta(days=1)
183
184
def _date_interval_day(d): return d + timedelta(days=1)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L183-L184
37
[ 0, 1 ]
100
[]
0
true
69.154229
2
1
100
0
def _date_interval_day(d): return d + timedelta(days=1)
22,996
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
_date_interval_hour
(d)
return d + timedelta(hours=1)
187
188
def _date_interval_hour(d): return d + timedelta(hours=1)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L187-L188
37
[ 0, 1 ]
100
[]
0
true
69.154229
2
1
100
0
def _date_interval_hour(d): return d + timedelta(hours=1)
22,997
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
Facet.__init__
(self, metric=None, metric_sort="desc", **kwargs)
45
50
def __init__(self, metric=None, metric_sort="desc", **kwargs): self.filter_values = () self._params = kwargs self._metric = metric if metric and metric_sort: self._params["order"] = {"metric": metric_sort}
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L45-L50
37
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
69.154229
6
3
100
0
def __init__(self, metric=None, metric_sort="desc", **kwargs): self.filter_values = () self._params = kwargs self._metric = metric if metric and metric_sort: self._params["order"] = {"metric": metric_sort}
22,998
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
Facet.get_aggregation
(self)
return agg
Return the aggregation object.
Return the aggregation object.
52
59
def get_aggregation(self): """ Return the aggregation object. """ agg = A(self.agg_type, **self._params) if self._metric: agg.metric("metric", self._metric) return agg
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L52-L59
37
[ 0, 1, 2, 3, 4, 5, 7 ]
87.5
[ 6 ]
12.5
false
69.154229
8
2
87.5
1
def get_aggregation(self): agg = A(self.agg_type, **self._params) if self._metric: agg.metric("metric", self._metric) return agg
22,999
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
Facet.add_filter
(self, filter_values)
return f
Construct a filter.
Construct a filter.
61
71
def add_filter(self, filter_values): """ Construct a filter. """ if not filter_values: return f = self.get_value_filter(filter_values[0]) for v in filter_values[1:]: f |= self.get_value_filter(v) return f
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L61-L71
37
[ 0, 1, 2, 3 ]
36.363636
[ 4, 5, 7, 8, 9, 10 ]
54.545455
false
69.154229
11
3
45.454545
1
def add_filter(self, filter_values): if not filter_values: return f = self.get_value_filter(filter_values[0]) for v in filter_values[1:]: f |= self.get_value_filter(v) return f
23,000
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
Facet.get_value_filter
(self, filter_value)
Construct a filter for an individual value
Construct a filter for an individual value
73
77
def get_value_filter(self, filter_value): """ Construct a filter for an individual value """ pass
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L73-L77
37
[ 0, 1, 2, 3 ]
80
[ 4 ]
20
false
69.154229
5
1
80
1
def get_value_filter(self, filter_value): pass
23,001
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
Facet.is_filtered
(self, key, filter_values)
return key in filter_values
Is a filter active on the given key.
Is a filter active on the given key.
79
83
def is_filtered(self, key, filter_values): """ Is a filter active on the given key. """ return key in filter_values
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L79-L83
37
[ 0, 1, 2, 3 ]
80
[ 4 ]
20
false
69.154229
5
1
80
1
def is_filtered(self, key, filter_values): return key in filter_values
23,002
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
Facet.get_value
(self, bucket)
return bucket["key"]
return a value representing a bucket. Its key as default.
return a value representing a bucket. Its key as default.
85
89
def get_value(self, bucket): """ return a value representing a bucket. Its key as default. """ return bucket["key"]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L85-L89
37
[ 0, 1, 2, 3 ]
80
[ 4 ]
20
false
69.154229
5
1
80
1
def get_value(self, bucket): return bucket["key"]
23,003
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
Facet.get_metric
(self, bucket)
return bucket["doc_count"]
Return a metric, by default doc_count for a bucket.
Return a metric, by default doc_count for a bucket.
91
97
def get_metric(self, bucket): """ Return a metric, by default doc_count for a bucket. """ if self._metric: return bucket["metric"]["value"] return bucket["doc_count"]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L91-L97
37
[ 0, 1, 2, 3 ]
57.142857
[ 4, 5, 6 ]
42.857143
false
69.154229
7
2
57.142857
1
def get_metric(self, bucket): if self._metric: return bucket["metric"]["value"] return bucket["doc_count"]
23,004
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
Facet.get_values
(self, data, filter_values)
return out
Turn the raw bucket data into a list of tuples containing the key, number of documents and a flag indicating whether this value has been selected or not.
Turn the raw bucket data into a list of tuples containing the key, number of documents and a flag indicating whether this value has been selected or not.
99
111
def get_values(self, data, filter_values): """ Turn the raw bucket data into a list of tuples containing the key, number of documents and a flag indicating whether this value has been selected or not. """ out = [] for bucket in data.buckets: key = self.get_value(bucket) out.append( (key, self.get_metric(bucket), self.is_filtered(key, filter_values)) ) return out
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L99-L111
37
[ 0, 1, 2, 3, 4, 5 ]
46.153846
[ 6, 7, 8, 9, 12 ]
38.461538
false
69.154229
13
2
61.538462
3
def get_values(self, data, filter_values): out = [] for bucket in data.buckets: key = self.get_value(bucket) out.append( (key, self.get_metric(bucket), self.is_filtered(key, filter_values)) ) return out
23,005
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
TermsFacet.add_filter
(self, filter_values)
Create a terms filter instead of bool containing term filters.
Create a terms filter instead of bool containing term filters.
117
122
def add_filter(self, filter_values): """Create a terms filter instead of bool containing term filters.""" if filter_values: return Terms( _expand__to_dot=False, **{self._params["field"]: filter_values} )
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L117-L122
37
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
69.154229
6
2
100
1
def add_filter(self, filter_values): if filter_values: return Terms( _expand__to_dot=False, **{self._params["field"]: filter_values} )
23,006
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
RangeFacet._range_to_dict
(self, range)
return out
128
135
def _range_to_dict(self, range): key, range = range out = {"key": key} if range[0] is not None: out["from"] = range[0] if range[1] is not None: out["to"] = range[1] return out
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L128-L135
37
[ 0 ]
12.5
[ 1, 2, 3, 4, 5, 6, 7 ]
87.5
false
69.154229
8
3
12.5
0
def _range_to_dict(self, range): key, range = range out = {"key": key} if range[0] is not None: out["from"] = range[0] if range[1] is not None: out["to"] = range[1] return out
23,007
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
RangeFacet.__init__
(self, ranges, **kwargs)
137
141
def __init__(self, ranges, **kwargs): super().__init__(**kwargs) self._params["ranges"] = list(map(self._range_to_dict, ranges)) self._params["keyed"] = False self._ranges = dict(ranges)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L137-L141
37
[ 0 ]
20
[ 1, 2, 3, 4 ]
80
false
69.154229
5
1
20
0
def __init__(self, ranges, **kwargs): super().__init__(**kwargs) self._params["ranges"] = list(map(self._range_to_dict, ranges)) self._params["keyed"] = False self._ranges = dict(ranges)
23,008
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
RangeFacet.get_value_filter
(self, filter_value)
return Range(_expand__to_dot=False, **{self._params["field"]: limits})
143
151
def get_value_filter(self, filter_value): f, t = self._ranges[filter_value] limits = {} if f is not None: limits["gte"] = f if t is not None: limits["lt"] = t return Range(_expand__to_dot=False, **{self._params["field"]: limits})
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L143-L151
37
[ 0 ]
11.111111
[ 1, 2, 3, 4, 5, 6, 8 ]
77.777778
false
69.154229
9
3
22.222222
0
def get_value_filter(self, filter_value): f, t = self._ranges[filter_value] limits = {} if f is not None: limits["gte"] = f if t is not None: limits["lt"] = t return Range(_expand__to_dot=False, **{self._params["field"]: limits})
23,009
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
HistogramFacet.get_value_filter
(self, filter_value)
return Range( _expand__to_dot=False, **{ self._params["field"]: { "gte": filter_value, "lt": filter_value + self._params["interval"], } }, )
157
166
def get_value_filter(self, filter_value): return Range( _expand__to_dot=False, **{ self._params["field"]: { "gte": filter_value, "lt": filter_value + self._params["interval"], } }, )
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L157-L166
37
[ 0 ]
10
[ 1 ]
10
false
69.154229
10
1
90
0
def get_value_filter(self, filter_value): return Range( _expand__to_dot=False, **{ self._params["field"]: { "gte": filter_value, "lt": filter_value + self._params["interval"], } }, )
23,010
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
DateHistogramFacet.__init__
(self, **kwargs)
207
209
def __init__(self, **kwargs): kwargs.setdefault("min_doc_count", 0) super().__init__(**kwargs)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L207-L209
37
[ 0, 1, 2 ]
100
[]
0
true
69.154229
3
1
100
0
def __init__(self, **kwargs): kwargs.setdefault("min_doc_count", 0) super().__init__(**kwargs)
23,011
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
DateHistogramFacet.get_value
(self, bucket)
211
220
def get_value(self, bucket): if not isinstance(bucket["key"], datetime): # Elasticsearch returns key=None instead of 0 for date 1970-01-01, # so we need to set key to 0 to avoid TypeError exception if bucket["key"] is None: bucket["key"] = 0 # Preserve milliseconds in the datetime return datetime.utcfromtimestamp(int(bucket["key"]) / 1000.0) else: return bucket["key"]
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L211-L220
37
[ 0, 1, 2, 3, 4, 5, 6, 7 ]
80
[ 9 ]
10
false
69.154229
10
3
90
0
def get_value(self, bucket): if not isinstance(bucket["key"], datetime): # Elasticsearch returns key=None instead of 0 for date 1970-01-01, # so we need to set key to 0 to avoid TypeError exception if bucket["key"] is None: bucket["key"] = 0 # Preserve milliseconds in the datetime return datetime.utcfromtimestamp(int(bucket["key"]) / 1000.0) else: return bucket["key"]
23,012
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
DateHistogramFacet.get_value_filter
(self, filter_value)
return Range( _expand__to_dot=False, **{ self._params["field"]: { "gte": filter_value, "lt": self.DATE_INTERVALS[self._params[interval_type]]( filter_value ), } }, )
222
239
def get_value_filter(self, filter_value): for interval_type in ("calendar_interval", "fixed_interval"): if interval_type in self._params: break else: interval_type = "interval" return Range( _expand__to_dot=False, **{ self._params["field"]: { "gte": filter_value, "lt": self.DATE_INTERVALS[self._params[interval_type]]( filter_value ), } }, )
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L222-L239
37
[ 0, 1, 2, 3, 5, 6, 7 ]
38.888889
[]
0
false
69.154229
18
3
100
0
def get_value_filter(self, filter_value): for interval_type in ("calendar_interval", "fixed_interval"): if interval_type in self._params: break else: interval_type = "interval" return Range( _expand__to_dot=False, **{ self._params["field"]: { "gte": filter_value, "lt": self.DATE_INTERVALS[self._params[interval_type]]( filter_value ), } }, )
23,013
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
NestedFacet.__init__
(self, path, nested_facet)
245
248
def __init__(self, path, nested_facet): self._path = path self._inner = nested_facet super().__init__(path=path, aggs={"inner": nested_facet.get_aggregation()})
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L245-L248
37
[ 0 ]
25
[ 1, 2, 3 ]
75
false
69.154229
4
1
25
0
def __init__(self, path, nested_facet): self._path = path self._inner = nested_facet super().__init__(path=path, aggs={"inner": nested_facet.get_aggregation()})
23,014
elastic/elasticsearch-dsl-py
5874ff6bd5a7a77086539159f041eb979b5235cc
elasticsearch_dsl/faceted_search.py
NestedFacet.get_values
(self, data, filter_values)
return self._inner.get_values(data.inner, filter_values)
250
251
def get_values(self, data, filter_values): return self._inner.get_values(data.inner, filter_values)
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/faceted_search.py#L250-L251
37
[ 0 ]
50
[ 1 ]
50
false
69.154229
2
1
50
0
def get_values(self, data, filter_values): return self._inner.get_values(data.inner, filter_values)
23,015