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/utils.py
|
DslBase.__getattr__
|
(self, name)
|
return value
| 315 | 341 |
def __getattr__(self, name):
if name.startswith("_"):
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {name!r}"
)
value = None
try:
value = self._params[name]
except KeyError:
# compound types should never throw AttributeError and return empty
# container instead
if name in self._param_defs:
pinfo = self._param_defs[name]
if pinfo.get("multi"):
value = self._params.setdefault(name, [])
elif pinfo.get("hash"):
value = self._params.setdefault(name, {})
if value is None:
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {name!r}"
)
# wrap nested dicts in AttrDict for convenient access
if isinstance(value, collections.abc.Mapping):
return AttrDict(value)
return value
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L315-L341
| 37 |
[
0,
1,
2,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
23,
24,
25,
26
] | 81.481481 |
[] | 0 | false | 91.5625 | 27 | 8 | 100 | 0 |
def __getattr__(self, name):
if name.startswith("_"):
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {name!r}"
)
value = None
try:
value = self._params[name]
except KeyError:
# compound types should never throw AttributeError and return empty
# container instead
if name in self._param_defs:
pinfo = self._param_defs[name]
if pinfo.get("multi"):
value = self._params.setdefault(name, [])
elif pinfo.get("hash"):
value = self._params.setdefault(name, {})
if value is None:
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {name!r}"
)
# wrap nested dicts in AttrDict for convenient access
if isinstance(value, collections.abc.Mapping):
return AttrDict(value)
return value
| 22,816 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase.to_dict
|
(self)
|
return {self.name: d}
|
Serialize the DSL object to plain dict
|
Serialize the DSL object to plain dict
| 343 | 380 |
def to_dict(self):
"""
Serialize the DSL object to plain dict
"""
d = {}
for pname, value in self._params.items():
pinfo = self._param_defs.get(pname)
# typed param
if pinfo and "type" in pinfo:
# don't serialize empty lists and dicts for typed fields
if value in ({}, []):
continue
# list of dict(name -> DslBase)
if pinfo.get("multi") and pinfo.get("hash"):
value = list(
{k: v.to_dict() for k, v in obj.items()} for obj in value
)
# multi-values are serialized as list of dicts
elif pinfo.get("multi"):
value = list(map(lambda x: x.to_dict(), value))
# squash all the hash values into one dict
elif pinfo.get("hash"):
value = {k: v.to_dict() for k, v in value.items()}
# serialize single values
else:
value = value.to_dict()
# serialize anything with to_dict method
elif hasattr(value, "to_dict"):
value = value.to_dict()
d[pname] = value
return {self.name: d}
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L343-L380
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
35,
36,
37
] | 86.842105 |
[
16,
34
] | 5.263158 | false | 91.5625 | 38 | 10 | 94.736842 | 1 |
def to_dict(self):
d = {}
for pname, value in self._params.items():
pinfo = self._param_defs.get(pname)
# typed param
if pinfo and "type" in pinfo:
# don't serialize empty lists and dicts for typed fields
if value in ({}, []):
continue
# list of dict(name -> DslBase)
if pinfo.get("multi") and pinfo.get("hash"):
value = list(
{k: v.to_dict() for k, v in obj.items()} for obj in value
)
# multi-values are serialized as list of dicts
elif pinfo.get("multi"):
value = list(map(lambda x: x.to_dict(), value))
# squash all the hash values into one dict
elif pinfo.get("hash"):
value = {k: v.to_dict() for k, v in value.items()}
# serialize single values
else:
value = value.to_dict()
# serialize anything with to_dict method
elif hasattr(value, "to_dict"):
value = value.to_dict()
d[pname] = value
return {self.name: d}
| 22,817 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase._clone
|
(self)
|
return c
| 382 | 386 |
def _clone(self):
c = self.__class__()
for attr in self._params:
c._params[attr] = copy(self._params[attr])
return c
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L382-L386
| 37 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 91.5625 | 5 | 2 | 100 | 0 |
def _clone(self):
c = self.__class__()
for attr in self._params:
c._params[attr] = copy(self._params[attr])
return c
| 22,818 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
HitMeta.__init__
|
(self, document, exclude=("_source", "_fields"))
| 390 | 399 |
def __init__(self, document, exclude=("_source", "_fields")):
d = {
k[1:] if k.startswith("_") else k: v
for (k, v) in document.items()
if k not in exclude
}
if "type" in d:
# make sure we are consistent everywhere in python
d["doc_type"] = d.pop("type")
super().__init__(d)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L390-L399
| 37 |
[
0,
1,
6,
7,
8,
9
] | 60 |
[] | 0 | false | 91.5625 | 10 | 2 | 100 | 0 |
def __init__(self, document, exclude=("_source", "_fields")):
d = {
k[1:] if k.startswith("_") else k: v
for (k, v) in document.items()
if k not in exclude
}
if "type" in d:
# make sure we are consistent everywhere in python
d["doc_type"] = d.pop("type")
super().__init__(d)
| 22,819 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.__init__
|
(self, meta=None, **kwargs)
| 403 | 411 |
def __init__(self, meta=None, **kwargs):
meta = meta or {}
for k in list(kwargs):
if k.startswith("_") and k[1:] in META_FIELDS:
meta[k] = kwargs.pop(k)
super(AttrDict, self).__setattr__("meta", HitMeta(meta))
super().__init__(kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L403-L411
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 91.5625 | 9 | 5 | 100 | 0 |
def __init__(self, meta=None, **kwargs):
meta = meta or {}
for k in list(kwargs):
if k.startswith("_") and k[1:] in META_FIELDS:
meta[k] = kwargs.pop(k)
super(AttrDict, self).__setattr__("meta", HitMeta(meta))
super().__init__(kwargs)
| 22,820 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.__list_fields
|
(cls)
|
Get all the fields defined for our class, if we have an Index, try
looking at the index mappings as well, mark the fields from Index as
optional.
|
Get all the fields defined for our class, if we have an Index, try
looking at the index mappings as well, mark the fields from Index as
optional.
| 414 | 432 |
def __list_fields(cls):
"""
Get all the fields defined for our class, if we have an Index, try
looking at the index mappings as well, mark the fields from Index as
optional.
"""
for name in cls._doc_type.mapping:
field = cls._doc_type.mapping[name]
yield name, field, False
if hasattr(cls.__class__, "_index"):
if not cls._index._mapping:
return
for name in cls._index._mapping:
# don't return fields that are in _doc_type
if name in cls._doc_type.mapping:
continue
field = cls._index._mapping[name]
yield name, field, True
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L414-L432
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 57.894737 |
[
11,
12,
13,
15,
16,
17,
18
] | 36.842105 | false | 91.5625 | 19 | 6 | 63.157895 | 3 |
def __list_fields(cls):
for name in cls._doc_type.mapping:
field = cls._doc_type.mapping[name]
yield name, field, False
if hasattr(cls.__class__, "_index"):
if not cls._index._mapping:
return
for name in cls._index._mapping:
# don't return fields that are in _doc_type
if name in cls._doc_type.mapping:
continue
field = cls._index._mapping[name]
yield name, field, True
| 22,821 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.__get_field
|
(cls, name)
| 435 | 444 |
def __get_field(cls, name):
try:
return cls._doc_type.mapping[name]
except KeyError:
# fallback to fields on the Index
if hasattr(cls, "_index") and cls._index._mapping:
try:
return cls._index._mapping[name]
except KeyError:
pass
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L435-L444
| 37 |
[
0,
1,
2,
3,
4,
5
] | 60 |
[
6,
7,
8,
9
] | 40 | false | 91.5625 | 10 | 5 | 60 | 0 |
def __get_field(cls, name):
try:
return cls._doc_type.mapping[name]
except KeyError:
# fallback to fields on the Index
if hasattr(cls, "_index") and cls._index._mapping:
try:
return cls._index._mapping[name]
except KeyError:
pass
| 22,822 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.from_es
|
(cls, hit)
|
return doc
| 447 | 452 |
def from_es(cls, hit):
meta = hit.copy()
data = meta.pop("_source", {})
doc = cls(meta=meta)
doc._from_dict(data)
return doc
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L447-L452
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 91.5625 | 6 | 1 | 100 | 0 |
def from_es(cls, hit):
meta = hit.copy()
data = meta.pop("_source", {})
doc = cls(meta=meta)
doc._from_dict(data)
return doc
| 22,823 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase._from_dict
|
(self, data)
| 454 | 459 |
def _from_dict(self, data):
for k, v in data.items():
f = self.__get_field(k)
if f and f._coerce:
v = f.deserialize(v)
setattr(self, k, v)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L454-L459
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 91.5625 | 6 | 4 | 100 | 0 |
def _from_dict(self, data):
for k, v in data.items():
f = self.__get_field(k)
if f and f._coerce:
v = f.deserialize(v)
setattr(self, k, v)
| 22,824 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.__getstate__
|
(self)
|
return self.to_dict(), self.meta._d_
| 461 | 462 |
def __getstate__(self):
return self.to_dict(), self.meta._d_
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L461-L462
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __getstate__(self):
return self.to_dict(), self.meta._d_
| 22,825 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.__setstate__
|
(self, state)
| 464 | 468 |
def __setstate__(self, state):
data, meta = state
super(AttrDict, self).__setattr__("_d_", {})
super(AttrDict, self).__setattr__("meta", HitMeta(meta))
self._from_dict(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L464-L468
| 37 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 91.5625 | 5 | 1 | 100 | 0 |
def __setstate__(self, state):
data, meta = state
super(AttrDict, self).__setattr__("_d_", {})
super(AttrDict, self).__setattr__("meta", HitMeta(meta))
self._from_dict(data)
| 22,826 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.__getattr__
|
(self, name)
| 470 | 481 |
def __getattr__(self, name):
try:
return super().__getattr__(name)
except AttributeError:
f = self.__get_field(name)
if hasattr(f, "empty"):
value = f.empty()
if value not in SKIP_VALUES:
setattr(self, name, value)
value = getattr(self, name)
return value
raise
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L470-L481
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 91.5625 | 12 | 4 | 100 | 0 |
def __getattr__(self, name):
try:
return super().__getattr__(name)
except AttributeError:
f = self.__get_field(name)
if hasattr(f, "empty"):
value = f.empty()
if value not in SKIP_VALUES:
setattr(self, name, value)
value = getattr(self, name)
return value
raise
| 22,827 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.to_dict
|
(self, skip_empty=True)
|
return out
| 483 | 502 |
def to_dict(self, skip_empty=True):
out = {}
for k, v in self._d_.items():
# if this is a mapped field,
f = self.__get_field(k)
if f and f._coerce:
v = f.serialize(v)
# if someone assigned AttrList, unwrap it
if isinstance(v, AttrList):
v = v._l_
if skip_empty:
# don't serialize empty values
# careful not to include numeric zeros
if v in ([], {}, None):
continue
out[k] = v
return out
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L483-L502
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
] | 100 |
[] | 0 | true | 91.5625 | 20 | 7 | 100 | 0 |
def to_dict(self, skip_empty=True):
out = {}
for k, v in self._d_.items():
# if this is a mapped field,
f = self.__get_field(k)
if f and f._coerce:
v = f.serialize(v)
# if someone assigned AttrList, unwrap it
if isinstance(v, AttrList):
v = v._l_
if skip_empty:
# don't serialize empty values
# careful not to include numeric zeros
if v in ([], {}, None):
continue
out[k] = v
return out
| 22,828 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.clean_fields
|
(self)
| 504 | 520 |
def clean_fields(self):
errors = {}
for name, field, optional in self.__list_fields():
data = self._d_.get(name, None)
if data is None and optional:
continue
try:
# save the cleaned value
data = field.clean(data)
except ValidationException as e:
errors.setdefault(name, []).append(e)
if name in self._d_ or data not in ([], {}, None):
self._d_[name] = data
if errors:
raise ValidationException(errors)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L504-L520
| 37 |
[
0,
1,
2,
3,
4,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
] | 94.117647 |
[
5
] | 5.882353 | false | 91.5625 | 17 | 8 | 94.117647 | 0 |
def clean_fields(self):
errors = {}
for name, field, optional in self.__list_fields():
data = self._d_.get(name, None)
if data is None and optional:
continue
try:
# save the cleaned value
data = field.clean(data)
except ValidationException as e:
errors.setdefault(name, []).append(e)
if name in self._d_ or data not in ([], {}, None):
self._d_[name] = data
if errors:
raise ValidationException(errors)
| 22,829 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
ObjectBase.full_clean
|
(self)
| 525 | 527 |
def full_clean(self):
self.clean_fields()
self.clean()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L525-L527
| 37 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 91.5625 | 3 | 1 | 100 | 0 |
def full_clean(self):
self.clean_fields()
self.clean()
| 22,830 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.__init__
|
(self, **kwargs)
|
Update by query 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).
|
Update by query request to elasticsearch.
| 29 | 44 |
def __init__(self, **kwargs):
"""
Update by query 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._response_class = UpdateByQueryResponse
self._script = {}
self._query_proxy = QueryProxy(self, "query")
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/update_by_query.py#L29-L44
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 |
[] | 0 | true | 94.827586 | 16 | 1 | 100 | 8 |
def __init__(self, **kwargs):
super().__init__(**kwargs)
self._response_class = UpdateByQueryResponse
self._script = {}
self._query_proxy = QueryProxy(self, "query")
| 22,831 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.filter
|
(self, *args, **kwargs)
|
return self.query(Bool(filter=[Q(*args, **kwargs)]))
| 46 | 47 |
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/update_by_query.py#L46-L47
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.827586 | 2 | 1 | 100 | 0 |
def filter(self, *args, **kwargs):
return self.query(Bool(filter=[Q(*args, **kwargs)]))
| 22,832 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.exclude
|
(self, *args, **kwargs)
|
return self.query(Bool(filter=[~Q(*args, **kwargs)]))
| 49 | 50 |
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/update_by_query.py#L49-L50
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.827586 | 2 | 1 | 100 | 0 |
def exclude(self, *args, **kwargs):
return self.query(Bool(filter=[~Q(*args, **kwargs)]))
| 22,833 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.from_dict
|
(cls, d)
|
return u
|
Construct a new `UpdateByQuery` instance from a raw dict containing the search
body. Useful when migrating from raw dictionaries.
Example::
ubq = UpdateByQuery.from_dict({
"query": {
"bool": {
"must": [...]
}
},
"script": {...}
})
ubq = ubq.filter('term', published=True)
|
Construct a new `UpdateByQuery` instance from a raw dict containing the search
body. Useful when migrating from raw dictionaries.
| 53 | 72 |
def from_dict(cls, d):
"""
Construct a new `UpdateByQuery` instance from a raw dict containing the search
body. Useful when migrating from raw dictionaries.
Example::
ubq = UpdateByQuery.from_dict({
"query": {
"bool": {
"must": [...]
}
},
"script": {...}
})
ubq = ubq.filter('term', published=True)
"""
u = cls()
u.update_from_dict(d)
return u
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/update_by_query.py#L53-L72
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
] | 100 |
[] | 0 | true | 94.827586 | 20 | 1 | 100 | 14 |
def from_dict(cls, d):
u = cls()
u.update_from_dict(d)
return u
| 22,834 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery._clone
|
(self)
|
return ubq
|
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.
| 74 | 85 |
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.
"""
ubq = super()._clone()
ubq._response_class = self._response_class
ubq._script = self._script.copy()
ubq.query._proxied = self.query._proxied
return ubq
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/update_by_query.py#L74-L85
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 94.827586 | 12 | 1 | 100 | 3 |
def _clone(self):
ubq = super()._clone()
ubq._response_class = self._response_class
ubq._script = self._script.copy()
ubq.query._proxied = self.query._proxied
return ubq
| 22,835 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.response_class
|
(self, cls)
|
return ubq
|
Override the default wrapper used for the response.
|
Override the default wrapper used for the response.
| 87 | 93 |
def response_class(self, cls):
"""
Override the default wrapper used for the response.
"""
ubq = self._clone()
ubq._response_class = cls
return ubq
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/update_by_query.py#L87-L93
| 37 |
[
0,
1,
2,
3
] | 57.142857 |
[
4,
5,
6
] | 42.857143 | false | 94.827586 | 7 | 1 | 57.142857 | 1 |
def response_class(self, cls):
ubq = self._clone()
ubq._response_class = cls
return ubq
| 22,836 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.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``.
| 95 | 106 |
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 "script" in d:
self._script = d.pop("script")
self._extra.update(d)
return self
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/update_by_query.py#L95-L106
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 94.827586 | 12 | 3 | 100 | 2 |
def update_from_dict(self, d):
d = d.copy()
if "query" in d:
self.query._proxied = Q(d.pop("query"))
if "script" in d:
self._script = d.pop("script")
self._extra.update(d)
return self
| 22,837 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.script
|
(self, **kwargs)
|
return ubq
|
Define update action to take:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html
for more details.
Note: the API only accepts a single script, so
calling the script multiple times will overwrite.
Example::
ubq = Search()
ubq = ubq.script(source="ctx._source.likes++"")
ubq = ubq.script(source="ctx._source.likes += params.f"",
lang="expression",
params={'f': 3})
|
Define update action to take:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html
for more details.
| 108 | 129 |
def script(self, **kwargs):
"""
Define update action to take:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html
for more details.
Note: the API only accepts a single script, so
calling the script multiple times will overwrite.
Example::
ubq = Search()
ubq = ubq.script(source="ctx._source.likes++"")
ubq = ubq.script(source="ctx._source.likes += params.f"",
lang="expression",
params={'f': 3})
"""
ubq = self._clone()
if ubq._script:
ubq._script = {}
ubq._script.update(kwargs)
return ubq
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/update_by_query.py#L108-L129
| 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 | 94.827586 | 22 | 2 | 100 | 14 |
def script(self, **kwargs):
ubq = self._clone()
if ubq._script:
ubq._script = {}
ubq._script.update(kwargs)
return ubq
| 22,838 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.to_dict
|
(self, **kwargs)
|
return d
|
Serialize the search into the dictionary that will be sent over as the
request'ubq body.
All additional keyword arguments will be included into the dictionary.
|
Serialize the search into the dictionary that will be sent over as the
request'ubq body.
| 131 | 147 |
def to_dict(self, **kwargs):
"""
Serialize the search into the dictionary that will be sent over as the
request'ubq body.
All additional keyword arguments will be included into the dictionary.
"""
d = {}
if self.query:
d["query"] = self.query.to_dict()
if self._script:
d["script"] = self._script
d.update(recursive_to_dict(self._extra))
d.update(recursive_to_dict(kwargs))
return d
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/update_by_query.py#L131-L147
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
] | 100 |
[] | 0 | true | 94.827586 | 17 | 3 | 100 | 4 |
def to_dict(self, **kwargs):
d = {}
if self.query:
d["query"] = self.query.to_dict()
if self._script:
d["script"] = self._script
d.update(recursive_to_dict(self._extra))
d.update(recursive_to_dict(kwargs))
return d
| 22,839 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/update_by_query.py
|
UpdateByQuery.execute
|
(self)
|
return self._response
|
Execute the search and return an instance of ``Response`` wrapping all
the data.
|
Execute the search and return an instance of ``Response`` wrapping all
the data.
| 149 | 160 |
def execute(self):
"""
Execute the search and return an instance of ``Response`` wrapping all
the data.
"""
es = get_connection(self._using)
self._response = self._response_class(
self,
es.update_by_query(index=self._index, body=self.to_dict(), **self._params),
)
return self._response
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/update_by_query.py#L149-L160
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 94.827586 | 12 | 1 | 100 | 2 |
def execute(self):
es = get_connection(self._using)
self._response = self._response_class(
self,
es.update_by_query(index=self._index, body=self.to_dict(), **self._params),
)
return self._response
| 22,840 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
IndexTemplate.__init__
|
(self, name, template, index=None, order=None, **kwargs)
| 28 | 40 |
def __init__(self, name, template, index=None, order=None, **kwargs):
if index is None:
self._index = Index(template, **kwargs)
else:
if kwargs:
raise ValueError(
"You cannot specify options for Index when"
" passing an Index instance."
)
self._index = index.clone()
self._index._name = template
self._template_name = name
self.order = order
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L28-L40
| 37 |
[
0,
1,
2,
4,
9,
10,
11,
12
] | 61.538462 |
[
5
] | 7.692308 | false | 63.861386 | 13 | 3 | 92.307692 | 0 |
def __init__(self, name, template, index=None, order=None, **kwargs):
if index is None:
self._index = Index(template, **kwargs)
else:
if kwargs:
raise ValueError(
"You cannot specify options for Index when"
" passing an Index instance."
)
self._index = index.clone()
self._index._name = template
self._template_name = name
self.order = order
| 22,841 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
IndexTemplate.__getattr__
|
(self, attr_name)
|
return getattr(self._index, attr_name)
| 42 | 43 |
def __getattr__(self, attr_name):
return getattr(self._index, attr_name)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L42-L43
| 37 |
[
0
] | 50 |
[
1
] | 50 | false | 63.861386 | 2 | 1 | 50 | 0 |
def __getattr__(self, attr_name):
return getattr(self._index, attr_name)
| 22,842 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
IndexTemplate.to_dict
|
(self)
|
return d
| 45 | 50 |
def to_dict(self):
d = self._index.to_dict()
d["index_patterns"] = [self._index._name]
if self.order is not None:
d["order"] = self.order
return d
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L45-L50
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 63.861386 | 6 | 2 | 100 | 0 |
def to_dict(self):
d = self._index.to_dict()
d["index_patterns"] = [self._index._name]
if self.order is not None:
d["order"] = self.order
return d
| 22,843 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
IndexTemplate.save
|
(self, using=None)
|
return es.indices.put_template(name=self._template_name, body=self.to_dict())
| 52 | 55 |
def save(self, using=None):
es = get_connection(using or self._index._using)
return es.indices.put_template(name=self._template_name, body=self.to_dict())
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L52-L55
| 37 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 63.861386 | 4 | 2 | 100 | 0 |
def save(self, using=None):
es = get_connection(using or self._index._using)
return es.indices.put_template(name=self._template_name, body=self.to_dict())
| 22,844 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.__init__
|
(self, name, using="default")
|
:arg name: name of the index
:arg using: connection alias to use, defaults to ``'default'``
|
:arg name: name of the index
:arg using: connection alias to use, defaults to ``'default'``
| 59 | 70 |
def __init__(self, name, using="default"):
"""
:arg name: name of the index
:arg using: connection alias to use, defaults to ``'default'``
"""
self._name = name
self._doc_types = []
self._using = using
self._settings = {}
self._aliases = {}
self._analysis = {}
self._mapping = None
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L59-L70
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 63.861386 | 12 | 1 | 100 | 2 |
def __init__(self, name, using="default"):
self._name = name
self._doc_types = []
self._using = using
self._settings = {}
self._aliases = {}
self._analysis = {}
self._mapping = None
| 22,845 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.get_or_create_mapping
|
(self)
|
return self._mapping
| 72 | 75 |
def get_or_create_mapping(self):
if self._mapping is None:
self._mapping = Mapping()
return self._mapping
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L72-L75
| 37 |
[
0
] | 25 |
[
1,
2,
3
] | 75 | false | 63.861386 | 4 | 2 | 25 | 0 |
def get_or_create_mapping(self):
if self._mapping is None:
self._mapping = Mapping()
return self._mapping
| 22,846 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.as_template
|
(self, template_name, pattern=None, order=None)
|
return IndexTemplate(
template_name, pattern or self._name, index=self, order=order
)
| 77 | 83 |
def as_template(self, template_name, pattern=None, order=None):
# TODO: should we allow pattern to be a top-level arg?
# or maybe have an IndexPattern that allows for it and have
# Document._index be that?
return IndexTemplate(
template_name, pattern or self._name, index=self, order=order
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L77-L83
| 37 |
[
0,
1,
2,
3,
4
] | 71.428571 |
[] | 0 | false | 63.861386 | 7 | 2 | 100 | 0 |
def as_template(self, template_name, pattern=None, order=None):
# TODO: should we allow pattern to be a top-level arg?
# or maybe have an IndexPattern that allows for it and have
# Document._index be that?
return IndexTemplate(
template_name, pattern or self._name, index=self, order=order
)
| 22,847 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.resolve_nested
|
(self, field_path)
|
return (), None
| 85 | 92 |
def resolve_nested(self, field_path):
for doc in self._doc_types:
nested, field = doc._doc_type.mapping.resolve_nested(field_path)
if field is not None:
return nested, field
if self._mapping:
return self._mapping.resolve_nested(field_path)
return (), None
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L85-L92
| 37 |
[
0,
1,
2,
3,
4
] | 62.5 |
[
5,
6,
7
] | 37.5 | false | 63.861386 | 8 | 4 | 62.5 | 0 |
def resolve_nested(self, field_path):
for doc in self._doc_types:
nested, field = doc._doc_type.mapping.resolve_nested(field_path)
if field is not None:
return nested, field
if self._mapping:
return self._mapping.resolve_nested(field_path)
return (), None
| 22,848 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.resolve_field
|
(self, field_path)
|
return None
| 94 | 101 |
def resolve_field(self, field_path):
for doc in self._doc_types:
field = doc._doc_type.mapping.resolve_field(field_path)
if field is not None:
return field
if self._mapping:
return self._mapping.resolve_field(field_path)
return None
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L94-L101
| 37 |
[
0,
1,
2,
3,
4
] | 62.5 |
[
5,
6,
7
] | 37.5 | false | 63.861386 | 8 | 4 | 62.5 | 0 |
def resolve_field(self, field_path):
for doc in self._doc_types:
field = doc._doc_type.mapping.resolve_field(field_path)
if field is not None:
return field
if self._mapping:
return self._mapping.resolve_field(field_path)
return None
| 22,849 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.load_mappings
|
(self, using=None)
| 103 | 106 |
def load_mappings(self, using=None):
self.get_or_create_mapping().update_from_es(
self._name, using=using or self._using
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L103-L106
| 37 |
[
0
] | 25 |
[
1
] | 25 | false | 63.861386 | 4 | 2 | 75 | 0 |
def load_mappings(self, using=None):
self.get_or_create_mapping().update_from_es(
self._name, using=using or self._using
)
| 22,850 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.clone
|
(self, name=None, using=None)
|
return i
|
Create a copy of the instance with another name or connection alias.
Useful for creating multiple indices with shared configuration::
i = Index('base-index')
i.settings(number_of_shards=1)
i.create()
i2 = i.clone('other-index')
i2.create()
:arg name: name of the index
:arg using: connection alias to use, defaults to ``'default'``
|
Create a copy of the instance with another name or connection alias.
Useful for creating multiple indices with shared configuration::
| 108 | 130 |
def clone(self, name=None, using=None):
"""
Create a copy of the instance with another name or connection alias.
Useful for creating multiple indices with shared configuration::
i = Index('base-index')
i.settings(number_of_shards=1)
i.create()
i2 = i.clone('other-index')
i2.create()
:arg name: name of the index
:arg using: connection alias to use, defaults to ``'default'``
"""
i = Index(name or self._name, using=using or self._using)
i._settings = self._settings.copy()
i._aliases = self._aliases.copy()
i._analysis = self._analysis.copy()
i._doc_types = self._doc_types[:]
if self._mapping is not None:
i._mapping = self._mapping._clone()
return i
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L108-L130
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
22
] | 95.652174 |
[
21
] | 4.347826 | false | 63.861386 | 23 | 4 | 95.652174 | 12 |
def clone(self, name=None, using=None):
i = Index(name or self._name, using=using or self._using)
i._settings = self._settings.copy()
i._aliases = self._aliases.copy()
i._analysis = self._analysis.copy()
i._doc_types = self._doc_types[:]
if self._mapping is not None:
i._mapping = self._mapping._clone()
return i
| 22,851 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index._get_connection
|
(self, using=None)
|
return get_connection(using or self._using)
| 132 | 135 |
def _get_connection(self, using=None):
if self._name is None:
raise ValueError("You cannot perform API calls on the default index.")
return get_connection(using or self._using)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L132-L135
| 37 |
[
0
] | 25 |
[
1,
2,
3
] | 75 | false | 63.861386 | 4 | 3 | 25 | 0 |
def _get_connection(self, using=None):
if self._name is None:
raise ValueError("You cannot perform API calls on the default index.")
return get_connection(using or self._using)
| 22,852 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.mapping
|
(self, mapping)
|
Associate a mapping (an instance of
:class:`~elasticsearch_dsl.Mapping`) with this index.
This means that, when this index is created, it will contain the
mappings for the document type defined by those mappings.
|
Associate a mapping (an instance of
:class:`~elasticsearch_dsl.Mapping`) with this index.
This means that, when this index is created, it will contain the
mappings for the document type defined by those mappings.
| 139 | 146 |
def mapping(self, mapping):
"""
Associate a mapping (an instance of
:class:`~elasticsearch_dsl.Mapping`) with this index.
This means that, when this index is created, it will contain the
mappings for the document type defined by those mappings.
"""
self.get_or_create_mapping().update(mapping)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L139-L146
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def mapping(self, mapping):
self.get_or_create_mapping().update(mapping)
| 22,853 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.document
|
(self, document)
|
return document
|
Associate a :class:`~elasticsearch_dsl.Document` subclass with an index.
This means that, when this index is created, it will contain the
mappings for the ``Document``. If the ``Document`` class doesn't have a
default index yet (by defining ``class Index``), this instance will be
used. Can be used as a decorator::
i = Index('blog')
@i.document
class Post(Document):
title = Text()
# create the index, including Post mappings
i.create()
# .search() will now return a Search object that will return
# properly deserialized Post instances
s = i.search()
|
Associate a :class:`~elasticsearch_dsl.Document` subclass with an index.
This means that, when this index is created, it will contain the
mappings for the ``Document``. If the ``Document`` class doesn't have a
default index yet (by defining ``class Index``), this instance will be
used. Can be used as a decorator::
| 148 | 177 |
def document(self, document):
"""
Associate a :class:`~elasticsearch_dsl.Document` subclass with an index.
This means that, when this index is created, it will contain the
mappings for the ``Document``. If the ``Document`` class doesn't have a
default index yet (by defining ``class Index``), this instance will be
used. Can be used as a decorator::
i = Index('blog')
@i.document
class Post(Document):
title = Text()
# create the index, including Post mappings
i.create()
# .search() will now return a Search object that will return
# properly deserialized Post instances
s = i.search()
"""
self._doc_types.append(document)
# If the document index does not have any name, that means the user
# did not set any index already to the document.
# So set this index as document index
if document._index._name is None:
document._index = self
return document
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L148-L177
| 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
] | 100 |
[] | 0 | true | 63.861386 | 30 | 2 | 100 | 18 |
def document(self, document):
self._doc_types.append(document)
# If the document index does not have any name, that means the user
# did not set any index already to the document.
# So set this index as document index
if document._index._name is None:
document._index = self
return document
| 22,854 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.settings
|
(self, **kwargs)
|
return self
|
Add settings to the index::
i = Index('i')
i.settings(number_of_shards=1, number_of_replicas=0)
Multiple calls to ``settings`` will merge the keys, later overriding
the earlier.
|
Add settings to the index::
| 179 | 190 |
def settings(self, **kwargs):
"""
Add settings to the index::
i = Index('i')
i.settings(number_of_shards=1, number_of_replicas=0)
Multiple calls to ``settings`` will merge the keys, later overriding
the earlier.
"""
self._settings.update(kwargs)
return self
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L179-L190
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 63.861386 | 12 | 1 | 100 | 7 |
def settings(self, **kwargs):
self._settings.update(kwargs)
return self
| 22,855 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.aliases
|
(self, **kwargs)
|
return self
|
Add aliases to the index definition::
i = Index('blog-v2')
i.aliases(blog={}, published={'filter': Q('term', published=True)})
|
Add aliases to the index definition::
| 192 | 200 |
def aliases(self, **kwargs):
"""
Add aliases to the index definition::
i = Index('blog-v2')
i.aliases(blog={}, published={'filter': Q('term', published=True)})
"""
self._aliases.update(kwargs)
return self
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L192-L200
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 63.861386 | 9 | 1 | 100 | 4 |
def aliases(self, **kwargs):
self._aliases.update(kwargs)
return self
| 22,856 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.analyzer
|
(self, *args, **kwargs)
|
Explicitly add an analyzer to an index. Note that all custom analyzers
defined in mappings will also be created. This is useful for search analyzers.
Example::
from elasticsearch_dsl import analyzer, tokenizer
my_analyzer = analyzer('my_analyzer',
tokenizer=tokenizer('trigram', 'nGram', min_gram=3, max_gram=3),
filter=['lowercase']
)
i = Index('blog')
i.analyzer(my_analyzer)
|
Explicitly add an analyzer to an index. Note that all custom analyzers
defined in mappings will also be created. This is useful for search analyzers.
| 202 | 227 |
def analyzer(self, *args, **kwargs):
"""
Explicitly add an analyzer to an index. Note that all custom analyzers
defined in mappings will also be created. This is useful for search analyzers.
Example::
from elasticsearch_dsl import analyzer, tokenizer
my_analyzer = analyzer('my_analyzer',
tokenizer=tokenizer('trigram', 'nGram', min_gram=3, max_gram=3),
filter=['lowercase']
)
i = Index('blog')
i.analyzer(my_analyzer)
"""
analyzer = analysis.analyzer(*args, **kwargs)
d = analyzer.get_analysis_definition()
# empty custom analyzer, probably already defined out of our control
if not d:
return
# merge the definition
merge(self._analysis, d, True)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L202-L227
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
24,
25
] | 92.307692 |
[
22
] | 3.846154 | false | 63.861386 | 26 | 2 | 96.153846 | 14 |
def analyzer(self, *args, **kwargs):
analyzer = analysis.analyzer(*args, **kwargs)
d = analyzer.get_analysis_definition()
# empty custom analyzer, probably already defined out of our control
if not d:
return
# merge the definition
merge(self._analysis, d, True)
| 22,857 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.to_dict
|
(self)
|
return out
| 229 | 246 |
def to_dict(self):
out = {}
if self._settings:
out["settings"] = self._settings
if self._aliases:
out["aliases"] = self._aliases
mappings = self._mapping.to_dict() if self._mapping else {}
analysis = self._mapping._collect_analysis() if self._mapping else {}
for d in self._doc_types:
mapping = d._doc_type.mapping
merge(mappings, mapping.to_dict(), True)
merge(analysis, mapping._collect_analysis(), True)
if mappings:
out["mappings"] = mappings
if analysis or self._analysis:
merge(analysis, self._analysis)
out.setdefault("settings", {})["analysis"] = analysis
return out
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L229-L246
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17
] | 100 |
[] | 0 | true | 63.861386 | 18 | 7 | 100 | 0 |
def to_dict(self):
out = {}
if self._settings:
out["settings"] = self._settings
if self._aliases:
out["aliases"] = self._aliases
mappings = self._mapping.to_dict() if self._mapping else {}
analysis = self._mapping._collect_analysis() if self._mapping else {}
for d in self._doc_types:
mapping = d._doc_type.mapping
merge(mappings, mapping.to_dict(), True)
merge(analysis, mapping._collect_analysis(), True)
if mappings:
out["mappings"] = mappings
if analysis or self._analysis:
merge(analysis, self._analysis)
out.setdefault("settings", {})["analysis"] = analysis
return out
| 22,858 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.search
|
(self, using=None)
|
return Search(
using=using or self._using, index=self._name, doc_type=self._doc_types
)
|
Return a :class:`~elasticsearch_dsl.Search` object searching over the
index (or all the indices belonging to this template) and its
``Document``\\s.
|
Return a :class:`~elasticsearch_dsl.Search` object searching over the
index (or all the indices belonging to this template) and its
``Document``\\s.
| 248 | 256 |
def search(self, using=None):
"""
Return a :class:`~elasticsearch_dsl.Search` object searching over the
index (or all the indices belonging to this template) and its
``Document``\\s.
"""
return Search(
using=using or self._using, index=self._name, doc_type=self._doc_types
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L248-L256
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 63.861386 | 9 | 2 | 100 | 3 |
def search(self, using=None):
return Search(
using=using or self._using, index=self._name, doc_type=self._doc_types
)
| 22,859 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.updateByQuery
|
(self, using=None)
|
return UpdateByQuery(
using=using or self._using,
index=self._name,
)
|
Return a :class:`~elasticsearch_dsl.UpdateByQuery` object searching over the index
(or all the indices belonging to this template) and updating Documents that match
the search criteria.
For more information, see here:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
|
Return a :class:`~elasticsearch_dsl.UpdateByQuery` object searching over the index
(or all the indices belonging to this template) and updating Documents that match
the search criteria.
| 258 | 270 |
def updateByQuery(self, using=None):
"""
Return a :class:`~elasticsearch_dsl.UpdateByQuery` object searching over the index
(or all the indices belonging to this template) and updating Documents that match
the search criteria.
For more information, see here:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
"""
return UpdateByQuery(
using=using or self._using,
index=self._name,
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L258-L270
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 69.230769 |
[
9
] | 7.692308 | false | 63.861386 | 13 | 2 | 92.307692 | 6 |
def updateByQuery(self, using=None):
return UpdateByQuery(
using=using or self._using,
index=self._name,
)
| 22,860 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.create
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.create(
index=self._name, body=self.to_dict(), **kwargs
)
|
Creates the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.create`` unchanged.
|
Creates the index in elasticsearch.
| 272 | 281 |
def create(self, using=None, **kwargs):
"""
Creates the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.create`` unchanged.
"""
return self._get_connection(using).indices.create(
index=self._name, body=self.to_dict(), **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L272-L281
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def create(self, using=None, **kwargs):
return self._get_connection(using).indices.create(
index=self._name, body=self.to_dict(), **kwargs
)
| 22,861 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.is_closed
|
(self, using=None)
|
return state["metadata"]["indices"][self._name]["state"] == "close"
| 283 | 287 |
def is_closed(self, using=None):
state = self._get_connection(using).cluster.state(
index=self._name, metric="metadata"
)
return state["metadata"]["indices"][self._name]["state"] == "close"
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L283-L287
| 37 |
[
0
] | 20 |
[
1,
4
] | 40 | false | 63.861386 | 5 | 1 | 60 | 0 |
def is_closed(self, using=None):
state = self._get_connection(using).cluster.state(
index=self._name, metric="metadata"
)
return state["metadata"]["indices"][self._name]["state"] == "close"
| 22,862 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.save
|
(self, using=None)
|
Sync the index definition with elasticsearch, creating the index if it
doesn't exist and updating its settings and mappings if it does.
Note some settings and mapping changes cannot be done on an open
index (or at all on an existing index) and for those this method will
fail with the underlying exception.
|
Sync the index definition with elasticsearch, creating the index if it
doesn't exist and updating its settings and mappings if it does.
| 289 | 341 |
def save(self, using=None):
"""
Sync the index definition with elasticsearch, creating the index if it
doesn't exist and updating its settings and mappings if it does.
Note some settings and mapping changes cannot be done on an open
index (or at all on an existing index) and for those this method will
fail with the underlying exception.
"""
if not self.exists(using=using):
return self.create(using=using)
body = self.to_dict()
settings = body.pop("settings", {})
analysis = settings.pop("analysis", None)
current_settings = self.get_settings(using=using)[self._name]["settings"][
"index"
]
if analysis:
if self.is_closed(using=using):
# closed index, update away
settings["analysis"] = analysis
else:
# compare analysis definition, if all analysis objects are
# already defined as requested, skip analysis update and
# proceed, otherwise raise IllegalOperation
existing_analysis = current_settings.get("analysis", {})
if any(
existing_analysis.get(section, {}).get(k, None)
!= analysis[section][k]
for section in analysis
for k in analysis[section]
):
raise IllegalOperation(
"You cannot update analysis configuration on an open index, "
"you need to close index %s first." % self._name
)
# try and update the settings
if settings:
settings = settings.copy()
for k, v in list(settings.items()):
if k in current_settings and current_settings[k] == str(v):
del settings[k]
if settings:
self.put_settings(using=using, body=settings)
# update the mappings, any conflict in the mappings will result in an
# exception
mappings = body.pop("mappings", {})
if mappings:
self.put_mapping(using=using, body=mappings)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L289-L341
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 16.981132 |
[
9,
10,
12,
13,
14,
15,
18,
19,
21,
26,
27,
33,
39,
40,
41,
42,
43,
45,
46,
50,
51,
52
] | 41.509434 | false | 63.861386 | 53 | 11 | 58.490566 | 6 |
def save(self, using=None):
if not self.exists(using=using):
return self.create(using=using)
body = self.to_dict()
settings = body.pop("settings", {})
analysis = settings.pop("analysis", None)
current_settings = self.get_settings(using=using)[self._name]["settings"][
"index"
]
if analysis:
if self.is_closed(using=using):
# closed index, update away
settings["analysis"] = analysis
else:
# compare analysis definition, if all analysis objects are
# already defined as requested, skip analysis update and
# proceed, otherwise raise IllegalOperation
existing_analysis = current_settings.get("analysis", {})
if any(
existing_analysis.get(section, {}).get(k, None)
!= analysis[section][k]
for section in analysis
for k in analysis[section]
):
raise IllegalOperation(
"You cannot update analysis configuration on an open index, "
"you need to close index %s first." % self._name
)
# try and update the settings
if settings:
settings = settings.copy()
for k, v in list(settings.items()):
if k in current_settings and current_settings[k] == str(v):
del settings[k]
if settings:
self.put_settings(using=using, body=settings)
# update the mappings, any conflict in the mappings will result in an
# exception
mappings = body.pop("mappings", {})
if mappings:
self.put_mapping(using=using, body=mappings)
| 22,863 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.analyze
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.analyze(index=self._name, **kwargs)
|
Perform the analysis process on a text and return the tokens breakdown
of the text.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.analyze`` unchanged.
|
Perform the analysis process on a text and return the tokens breakdown
of the text.
| 343 | 351 |
def analyze(self, using=None, **kwargs):
"""
Perform the analysis process on a text and return the tokens breakdown
of the text.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.analyze`` unchanged.
"""
return self._get_connection(using).indices.analyze(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L343-L351
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 88.888889 |
[
8
] | 11.111111 | false | 63.861386 | 9 | 1 | 88.888889 | 5 |
def analyze(self, using=None, **kwargs):
return self._get_connection(using).indices.analyze(index=self._name, **kwargs)
| 22,864 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.refresh
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.refresh(index=self._name, **kwargs)
|
Performs a refresh operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.refresh`` unchanged.
|
Performs a refresh operation on the index.
| 353 | 360 |
def refresh(self, using=None, **kwargs):
"""
Performs a refresh operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.refresh`` unchanged.
"""
return self._get_connection(using).indices.refresh(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L353-L360
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def refresh(self, using=None, **kwargs):
return self._get_connection(using).indices.refresh(index=self._name, **kwargs)
| 22,865 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.flush
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.flush(index=self._name, **kwargs)
|
Performs a flush operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.flush`` unchanged.
|
Performs a flush operation on the index.
| 362 | 369 |
def flush(self, using=None, **kwargs):
"""
Performs a flush operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.flush`` unchanged.
"""
return self._get_connection(using).indices.flush(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L362-L369
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def flush(self, using=None, **kwargs):
return self._get_connection(using).indices.flush(index=self._name, **kwargs)
| 22,866 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.get
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.get(index=self._name, **kwargs)
|
The get index API allows to retrieve information about the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get`` unchanged.
|
The get index API allows to retrieve information about the index.
| 371 | 378 |
def get(self, using=None, **kwargs):
"""
The get index API allows to retrieve information about the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get`` unchanged.
"""
return self._get_connection(using).indices.get(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L371-L378
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def get(self, using=None, **kwargs):
return self._get_connection(using).indices.get(index=self._name, **kwargs)
| 22,867 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.open
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.open(index=self._name, **kwargs)
|
Opens the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.open`` unchanged.
|
Opens the index in elasticsearch.
| 380 | 387 |
def open(self, using=None, **kwargs):
"""
Opens the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.open`` unchanged.
"""
return self._get_connection(using).indices.open(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L380-L387
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def open(self, using=None, **kwargs):
return self._get_connection(using).indices.open(index=self._name, **kwargs)
| 22,868 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.close
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.close(index=self._name, **kwargs)
|
Closes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.close`` unchanged.
|
Closes the index in elasticsearch.
| 389 | 396 |
def close(self, using=None, **kwargs):
"""
Closes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.close`` unchanged.
"""
return self._get_connection(using).indices.close(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L389-L396
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def close(self, using=None, **kwargs):
return self._get_connection(using).indices.close(index=self._name, **kwargs)
| 22,869 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.delete
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.delete(index=self._name, **kwargs)
|
Deletes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete`` unchanged.
|
Deletes the index in elasticsearch.
| 398 | 405 |
def delete(self, using=None, **kwargs):
"""
Deletes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete`` unchanged.
"""
return self._get_connection(using).indices.delete(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L398-L405
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def delete(self, using=None, **kwargs):
return self._get_connection(using).indices.delete(index=self._name, **kwargs)
| 22,870 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.exists
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.exists(index=self._name, **kwargs)
|
Returns ``True`` if the index already exists in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists`` unchanged.
|
Returns ``True`` if the index already exists in elasticsearch.
| 407 | 414 |
def exists(self, using=None, **kwargs):
"""
Returns ``True`` if the index already exists in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists`` unchanged.
"""
return self._get_connection(using).indices.exists(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L407-L414
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def exists(self, using=None, **kwargs):
return self._get_connection(using).indices.exists(index=self._name, **kwargs)
| 22,871 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.exists_type
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.exists_type(
index=self._name, **kwargs
)
|
Check if a type/types exists in the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists_type`` unchanged.
|
Check if a type/types exists in the index.
| 416 | 425 |
def exists_type(self, using=None, **kwargs):
"""
Check if a type/types exists in the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists_type`` unchanged.
"""
return self._get_connection(using).indices.exists_type(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L416-L425
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def exists_type(self, using=None, **kwargs):
return self._get_connection(using).indices.exists_type(
index=self._name, **kwargs
)
| 22,872 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.put_mapping
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.put_mapping(
index=self._name, **kwargs
)
|
Register specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_mapping`` unchanged.
|
Register specific mapping definition for a specific type.
| 427 | 436 |
def put_mapping(self, using=None, **kwargs):
"""
Register specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_mapping`` unchanged.
"""
return self._get_connection(using).indices.put_mapping(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L427-L436
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def put_mapping(self, using=None, **kwargs):
return self._get_connection(using).indices.put_mapping(
index=self._name, **kwargs
)
| 22,873 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.get_mapping
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.get_mapping(
index=self._name, **kwargs
)
|
Retrieve specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_mapping`` unchanged.
|
Retrieve specific mapping definition for a specific type.
| 438 | 447 |
def get_mapping(self, using=None, **kwargs):
"""
Retrieve specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_mapping`` unchanged.
"""
return self._get_connection(using).indices.get_mapping(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L438-L447
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def get_mapping(self, using=None, **kwargs):
return self._get_connection(using).indices.get_mapping(
index=self._name, **kwargs
)
| 22,874 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.get_field_mapping
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.get_field_mapping(
index=self._name, **kwargs
)
|
Retrieve mapping definition of a specific field.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_field_mapping`` unchanged.
|
Retrieve mapping definition of a specific field.
| 449 | 458 |
def get_field_mapping(self, using=None, **kwargs):
"""
Retrieve mapping definition of a specific field.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_field_mapping`` unchanged.
"""
return self._get_connection(using).indices.get_field_mapping(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L449-L458
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def get_field_mapping(self, using=None, **kwargs):
return self._get_connection(using).indices.get_field_mapping(
index=self._name, **kwargs
)
| 22,875 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.put_alias
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.put_alias(index=self._name, **kwargs)
|
Create an alias for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_alias`` unchanged.
|
Create an alias for the index.
| 460 | 467 |
def put_alias(self, using=None, **kwargs):
"""
Create an alias for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_alias`` unchanged.
"""
return self._get_connection(using).indices.put_alias(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L460-L467
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def put_alias(self, using=None, **kwargs):
return self._get_connection(using).indices.put_alias(index=self._name, **kwargs)
| 22,876 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.exists_alias
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.exists_alias(
index=self._name, **kwargs
)
|
Return a boolean indicating whether given alias exists for this index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists_alias`` unchanged.
|
Return a boolean indicating whether given alias exists for this index.
| 469 | 478 |
def exists_alias(self, using=None, **kwargs):
"""
Return a boolean indicating whether given alias exists for this index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists_alias`` unchanged.
"""
return self._get_connection(using).indices.exists_alias(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L469-L478
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def exists_alias(self, using=None, **kwargs):
return self._get_connection(using).indices.exists_alias(
index=self._name, **kwargs
)
| 22,877 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.get_alias
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.get_alias(index=self._name, **kwargs)
|
Retrieve a specified alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_alias`` unchanged.
|
Retrieve a specified alias.
| 480 | 487 |
def get_alias(self, using=None, **kwargs):
"""
Retrieve a specified alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_alias`` unchanged.
"""
return self._get_connection(using).indices.get_alias(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L480-L487
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def get_alias(self, using=None, **kwargs):
return self._get_connection(using).indices.get_alias(index=self._name, **kwargs)
| 22,878 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.delete_alias
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.delete_alias(
index=self._name, **kwargs
)
|
Delete specific alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete_alias`` unchanged.
|
Delete specific alias.
| 489 | 498 |
def delete_alias(self, using=None, **kwargs):
"""
Delete specific alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete_alias`` unchanged.
"""
return self._get_connection(using).indices.delete_alias(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L489-L498
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def delete_alias(self, using=None, **kwargs):
return self._get_connection(using).indices.delete_alias(
index=self._name, **kwargs
)
| 22,879 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.get_settings
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.get_settings(
index=self._name, **kwargs
)
|
Retrieve settings for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_settings`` unchanged.
|
Retrieve settings for the index.
| 500 | 509 |
def get_settings(self, using=None, **kwargs):
"""
Retrieve settings for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_settings`` unchanged.
"""
return self._get_connection(using).indices.get_settings(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L500-L509
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def get_settings(self, using=None, **kwargs):
return self._get_connection(using).indices.get_settings(
index=self._name, **kwargs
)
| 22,880 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.put_settings
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.put_settings(
index=self._name, **kwargs
)
|
Change specific index level settings in real time.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_settings`` unchanged.
|
Change specific index level settings in real time.
| 511 | 520 |
def put_settings(self, using=None, **kwargs):
"""
Change specific index level settings in real time.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_settings`` unchanged.
"""
return self._get_connection(using).indices.put_settings(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L511-L520
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def put_settings(self, using=None, **kwargs):
return self._get_connection(using).indices.put_settings(
index=self._name, **kwargs
)
| 22,881 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.stats
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.stats(index=self._name, **kwargs)
|
Retrieve statistics on different operations happening on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.stats`` unchanged.
|
Retrieve statistics on different operations happening on the index.
| 522 | 529 |
def stats(self, using=None, **kwargs):
"""
Retrieve statistics on different operations happening on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.stats`` unchanged.
"""
return self._get_connection(using).indices.stats(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L522-L529
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def stats(self, using=None, **kwargs):
return self._get_connection(using).indices.stats(index=self._name, **kwargs)
| 22,882 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.segments
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.segments(index=self._name, **kwargs)
|
Provide low level segments information that a Lucene index (shard
level) is built with.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.segments`` unchanged.
|
Provide low level segments information that a Lucene index (shard
level) is built with.
| 531 | 539 |
def segments(self, using=None, **kwargs):
"""
Provide low level segments information that a Lucene index (shard
level) is built with.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.segments`` unchanged.
"""
return self._get_connection(using).indices.segments(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L531-L539
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 88.888889 |
[
8
] | 11.111111 | false | 63.861386 | 9 | 1 | 88.888889 | 5 |
def segments(self, using=None, **kwargs):
return self._get_connection(using).indices.segments(index=self._name, **kwargs)
| 22,883 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.validate_query
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.validate_query(
index=self._name, **kwargs
)
|
Validate a potentially expensive query without executing it.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.validate_query`` unchanged.
|
Validate a potentially expensive query without executing it.
| 541 | 550 |
def validate_query(self, using=None, **kwargs):
"""
Validate a potentially expensive query without executing it.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.validate_query`` unchanged.
"""
return self._get_connection(using).indices.validate_query(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L541-L550
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def validate_query(self, using=None, **kwargs):
return self._get_connection(using).indices.validate_query(
index=self._name, **kwargs
)
| 22,884 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.clear_cache
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.clear_cache(
index=self._name, **kwargs
)
|
Clear all caches or specific cached associated with the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.clear_cache`` unchanged.
|
Clear all caches or specific cached associated with the index.
| 552 | 561 |
def clear_cache(self, using=None, **kwargs):
"""
Clear all caches or specific cached associated with the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.clear_cache`` unchanged.
"""
return self._get_connection(using).indices.clear_cache(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L552-L561
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def clear_cache(self, using=None, **kwargs):
return self._get_connection(using).indices.clear_cache(
index=self._name, **kwargs
)
| 22,885 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.recovery
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.recovery(index=self._name, **kwargs)
|
The indices recovery API provides insight into on-going shard
recoveries for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.recovery`` unchanged.
|
The indices recovery API provides insight into on-going shard
recoveries for the index.
| 563 | 571 |
def recovery(self, using=None, **kwargs):
"""
The indices recovery API provides insight into on-going shard
recoveries for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.recovery`` unchanged.
"""
return self._get_connection(using).indices.recovery(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L563-L571
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 88.888889 |
[
8
] | 11.111111 | false | 63.861386 | 9 | 1 | 88.888889 | 5 |
def recovery(self, using=None, **kwargs):
return self._get_connection(using).indices.recovery(index=self._name, **kwargs)
| 22,886 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.upgrade
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.upgrade(index=self._name, **kwargs)
|
Upgrade the index to the latest format.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.upgrade`` unchanged.
|
Upgrade the index to the latest format.
| 573 | 580 |
def upgrade(self, using=None, **kwargs):
"""
Upgrade the index to the latest format.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.upgrade`` unchanged.
"""
return self._get_connection(using).indices.upgrade(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L573-L580
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 63.861386 | 8 | 1 | 87.5 | 4 |
def upgrade(self, using=None, **kwargs):
return self._get_connection(using).indices.upgrade(index=self._name, **kwargs)
| 22,887 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.get_upgrade
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.get_upgrade(
index=self._name, **kwargs
)
|
Monitor how much of the index is upgraded.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_upgrade`` unchanged.
|
Monitor how much of the index is upgraded.
| 582 | 591 |
def get_upgrade(self, using=None, **kwargs):
"""
Monitor how much of the index is upgraded.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_upgrade`` unchanged.
"""
return self._get_connection(using).indices.get_upgrade(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L582-L591
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7
] | 10 | false | 63.861386 | 10 | 1 | 90 | 4 |
def get_upgrade(self, using=None, **kwargs):
return self._get_connection(using).indices.get_upgrade(
index=self._name, **kwargs
)
| 22,888 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.flush_synced
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.flush_synced(
index=self._name, **kwargs
)
|
Perform a normal flush, then add a generated unique marker (sync_id) to
all shards.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.flush_synced`` unchanged.
|
Perform a normal flush, then add a generated unique marker (sync_id) to
all shards.
| 593 | 603 |
def flush_synced(self, using=None, **kwargs):
"""
Perform a normal flush, then add a generated unique marker (sync_id) to
all shards.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.flush_synced`` unchanged.
"""
return self._get_connection(using).indices.flush_synced(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L593-L603
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 72.727273 |
[
8
] | 9.090909 | false | 63.861386 | 11 | 1 | 90.909091 | 5 |
def flush_synced(self, using=None, **kwargs):
return self._get_connection(using).indices.flush_synced(
index=self._name, **kwargs
)
| 22,889 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.shard_stores
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.shard_stores(
index=self._name, **kwargs
)
|
Provides store information for shard copies of the index. Store
information reports on which nodes shard copies exist, the shard copy
version, indicating how recent they are, and any exceptions encountered
while opening the shard index or from earlier engine failure.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.shard_stores`` unchanged.
|
Provides store information for shard copies of the index. Store
information reports on which nodes shard copies exist, the shard copy
version, indicating how recent they are, and any exceptions encountered
while opening the shard index or from earlier engine failure.
| 605 | 617 |
def shard_stores(self, using=None, **kwargs):
"""
Provides store information for shard copies of the index. Store
information reports on which nodes shard copies exist, the shard copy
version, indicating how recent they are, and any exceptions encountered
while opening the shard index or from earlier engine failure.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.shard_stores`` unchanged.
"""
return self._get_connection(using).indices.shard_stores(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L605-L617
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 76.923077 |
[
10
] | 7.692308 | false | 63.861386 | 13 | 1 | 92.307692 | 7 |
def shard_stores(self, using=None, **kwargs):
return self._get_connection(using).indices.shard_stores(
index=self._name, **kwargs
)
| 22,890 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.forcemerge
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.forcemerge(
index=self._name, **kwargs
)
|
The force merge API allows to force merging of the index through an
API. The merge relates to the number of segments a Lucene index holds
within each shard. The force merge operation allows to reduce the
number of segments by merging them.
This call will block until the merge is complete. If the http
connection is lost, the request will continue in the background, and
any new requests will block until the previous force merge is complete.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.forcemerge`` unchanged.
|
The force merge API allows to force merging of the index through an
API. The merge relates to the number of segments a Lucene index holds
within each shard. The force merge operation allows to reduce the
number of segments by merging them.
| 619 | 635 |
def forcemerge(self, using=None, **kwargs):
"""
The force merge API allows to force merging of the index through an
API. The merge relates to the number of segments a Lucene index holds
within each shard. The force merge operation allows to reduce the
number of segments by merging them.
This call will block until the merge is complete. If the http
connection is lost, the request will continue in the background, and
any new requests will block until the previous force merge is complete.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.forcemerge`` unchanged.
"""
return self._get_connection(using).indices.forcemerge(
index=self._name, **kwargs
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L619-L635
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 82.352941 |
[
14
] | 5.882353 | false | 63.861386 | 17 | 1 | 94.117647 | 11 |
def forcemerge(self, using=None, **kwargs):
return self._get_connection(using).indices.forcemerge(
index=self._name, **kwargs
)
| 22,891 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/index.py
|
Index.shrink
|
(self, using=None, **kwargs)
|
return self._get_connection(using).indices.shrink(index=self._name, **kwargs)
|
The shrink index API allows you to shrink an existing index into a new
index with fewer primary shards. The number of primary shards in the
target index must be a factor of the shards in the source index. For
example an index with 8 primary shards can be shrunk into 4, 2 or 1
primary shards or an index with 15 primary shards can be shrunk into 5,
3 or 1. If the number of shards in the index is a prime number it can
only be shrunk into a single primary shard. Before shrinking, a
(primary or replica) copy of every shard in the index must be present
on the same node.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.shrink`` unchanged.
|
The shrink index API allows you to shrink an existing index into a new
index with fewer primary shards. The number of primary shards in the
target index must be a factor of the shards in the source index. For
example an index with 8 primary shards can be shrunk into 4, 2 or 1
primary shards or an index with 15 primary shards can be shrunk into 5,
3 or 1. If the number of shards in the index is a prime number it can
only be shrunk into a single primary shard. Before shrinking, a
(primary or replica) copy of every shard in the index must be present
on the same node.
| 637 | 652 |
def shrink(self, using=None, **kwargs):
"""
The shrink index API allows you to shrink an existing index into a new
index with fewer primary shards. The number of primary shards in the
target index must be a factor of the shards in the source index. For
example an index with 8 primary shards can be shrunk into 4, 2 or 1
primary shards or an index with 15 primary shards can be shrunk into 5,
3 or 1. If the number of shards in the index is a prime number it can
only be shrunk into a single primary shard. Before shrinking, a
(primary or replica) copy of every shard in the index must be present
on the same node.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.shrink`` unchanged.
"""
return self._get_connection(using).indices.shrink(index=self._name, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/index.py#L637-L652
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 93.75 |
[
15
] | 6.25 | false | 63.861386 | 16 | 1 | 93.75 | 12 |
def shrink(self, using=None, **kwargs):
return self._get_connection(using).indices.shrink(index=self._name, **kwargs)
| 22,892 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
QueryProxy.__init__
|
(self, search, attr_name)
| 39 | 42 |
def __init__(self, search, attr_name):
self._search = search
self._proxied = None
self._attr_name = attr_name
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L39-L42
| 37 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 82.288828 | 4 | 1 | 100 | 0 |
def __init__(self, search, attr_name):
self._search = search
self._proxied = None
self._attr_name = attr_name
| 22,893 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
QueryProxy.__nonzero__
|
(self)
|
return self._proxied is not None
| 44 | 45 |
def __nonzero__(self):
return self._proxied is not None
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L44-L45
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 82.288828 | 2 | 1 | 100 | 0 |
def __nonzero__(self):
return self._proxied is not None
| 22,894 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
QueryProxy.__call__
|
(self, *args, **kwargs)
|
return s
| 49 | 61 |
def __call__(self, *args, **kwargs):
s = self._search._clone()
# we cannot use self._proxied since we just cloned self._search and
# need to access the new self on the clone
proxied = getattr(s, self._attr_name)
if proxied._proxied is None:
proxied._proxied = Q(*args, **kwargs)
else:
proxied._proxied &= Q(*args, **kwargs)
# always return search to be chainable
return s
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L49-L61
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
9,
10,
11,
12
] | 92.307692 |
[] | 0 | false | 82.288828 | 13 | 2 | 100 | 0 |
def __call__(self, *args, **kwargs):
s = self._search._clone()
# we cannot use self._proxied since we just cloned self._search and
# need to access the new self on the clone
proxied = getattr(s, self._attr_name)
if proxied._proxied is None:
proxied._proxied = Q(*args, **kwargs)
else:
proxied._proxied &= Q(*args, **kwargs)
# always return search to be chainable
return s
| 22,895 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
QueryProxy.__getattr__
|
(self, attr_name)
|
return getattr(self._proxied, attr_name)
| 63 | 64 |
def __getattr__(self, attr_name):
return getattr(self._proxied, attr_name)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L63-L64
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 82.288828 | 2 | 1 | 100 | 0 |
def __getattr__(self, attr_name):
return getattr(self._proxied, attr_name)
| 22,896 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
QueryProxy.__setattr__
|
(self, attr_name, value)
| 66 | 70 |
def __setattr__(self, attr_name, value):
if not attr_name.startswith("_"):
self._proxied = Q(self._proxied.to_dict())
setattr(self._proxied, attr_name, value)
super().__setattr__(attr_name, value)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L66-L70
| 37 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 82.288828 | 5 | 2 | 100 | 0 |
def __setattr__(self, attr_name, value):
if not attr_name.startswith("_"):
self._proxied = Q(self._proxied.to_dict())
setattr(self._proxied, attr_name, value)
super().__setattr__(attr_name, value)
| 22,897 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
QueryProxy.__getstate__
|
(self)
|
return self._search, self._proxied, self._attr_name
| 72 | 73 |
def __getstate__(self):
return self._search, self._proxied, self._attr_name
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L72-L73
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 82.288828 | 2 | 1 | 100 | 0 |
def __getstate__(self):
return self._search, self._proxied, self._attr_name
| 22,898 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
QueryProxy.__setstate__
|
(self, state)
| 75 | 76 |
def __setstate__(self, state):
self._search, self._proxied, self._attr_name = state
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L75-L76
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 82.288828 | 2 | 1 | 100 | 0 |
def __setstate__(self, state):
self._search, self._proxied, self._attr_name = state
| 22,899 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
ProxyDescriptor.__init__
|
(self, name)
| 88 | 89 |
def __init__(self, name):
self._attr_name = f"_{name}_proxy"
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L88-L89
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 82.288828 | 2 | 1 | 100 | 0 |
def __init__(self, name):
self._attr_name = f"_{name}_proxy"
| 22,900 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
ProxyDescriptor.__get__
|
(self, instance, owner)
|
return getattr(instance, self._attr_name)
| 91 | 92 |
def __get__(self, instance, owner):
return getattr(instance, self._attr_name)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L91-L92
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 82.288828 | 2 | 1 | 100 | 0 |
def __get__(self, instance, owner):
return getattr(instance, self._attr_name)
| 22,901 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
ProxyDescriptor.__set__
|
(self, instance, value)
| 94 | 96 |
def __set__(self, instance, value):
proxy = getattr(instance, self._attr_name)
proxy._proxied = Q(value)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L94-L96
| 37 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 82.288828 | 3 | 1 | 100 | 0 |
def __set__(self, instance, value):
proxy = getattr(instance, self._attr_name)
proxy._proxied = Q(value)
| 22,902 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
AggsProxy.__init__
|
(self, search)
| 102 | 105 |
def __init__(self, search):
self._base = self
self._search = search
self._params = {"aggs": {}}
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L102-L105
| 37 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 82.288828 | 4 | 1 | 100 | 0 |
def __init__(self, search):
self._base = self
self._search = search
self._params = {"aggs": {}}
| 22,903 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
AggsProxy.to_dict
|
(self)
|
return super().to_dict().get("aggs", {})
| 107 | 108 |
def to_dict(self):
return super().to_dict().get("aggs", {})
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L107-L108
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 82.288828 | 2 | 1 | 100 | 0 |
def to_dict(self):
return super().to_dict().get("aggs", {})
| 22,904 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request.__init__
|
(self, using="default", index=None, doc_type=None, extra=None)
| 112 | 132 |
def __init__(self, using="default", index=None, doc_type=None, extra=None):
self._using = using
self._index = None
if isinstance(index, (tuple, list)):
self._index = list(index)
elif index:
self._index = [index]
self._doc_type = []
self._doc_type_map = {}
if isinstance(doc_type, (tuple, list)):
self._doc_type.extend(doc_type)
elif isinstance(doc_type, collections.abc.Mapping):
self._doc_type.extend(doc_type.keys())
self._doc_type_map.update(doc_type)
elif doc_type:
self._doc_type.append(doc_type)
self._params = {}
self._extra = extra or {}
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L112-L132
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
16,
17,
18,
19,
20
] | 90.47619 |
[
14,
15
] | 9.52381 | false | 82.288828 | 21 | 7 | 90.47619 | 0 |
def __init__(self, using="default", index=None, doc_type=None, extra=None):
self._using = using
self._index = None
if isinstance(index, (tuple, list)):
self._index = list(index)
elif index:
self._index = [index]
self._doc_type = []
self._doc_type_map = {}
if isinstance(doc_type, (tuple, list)):
self._doc_type.extend(doc_type)
elif isinstance(doc_type, collections.abc.Mapping):
self._doc_type.extend(doc_type.keys())
self._doc_type_map.update(doc_type)
elif doc_type:
self._doc_type.append(doc_type)
self._params = {}
self._extra = extra or {}
| 22,905 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request.__eq__
|
(self, other)
|
return (
isinstance(other, Request)
and other._params == self._params
and other._index == self._index
and other._doc_type == self._doc_type
and other.to_dict() == self.to_dict()
)
| 134 | 141 |
def __eq__(self, other):
return (
isinstance(other, Request)
and other._params == self._params
and other._index == self._index
and other._doc_type == self._doc_type
and other.to_dict() == self.to_dict()
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L134-L141
| 37 |
[
0,
1
] | 25 |
[] | 0 | false | 82.288828 | 8 | 5 | 100 | 0 |
def __eq__(self, other):
return (
isinstance(other, Request)
and other._params == self._params
and other._index == self._index
and other._doc_type == self._doc_type
and other.to_dict() == self.to_dict()
)
| 22,906 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request.__copy__
|
(self)
|
return self._clone()
| 143 | 144 |
def __copy__(self):
return self._clone()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L143-L144
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 82.288828 | 2 | 1 | 100 | 0 |
def __copy__(self):
return self._clone()
| 22,907 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request.params
|
(self, **kwargs)
|
return s
|
Specify query params to be used when executing the search. All the
keyword arguments will override the current values. See
https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.search
for all available parameters.
Example::
s = Search()
s = s.params(routing='user-1', preference='local')
|
Specify query params to be used when executing the search. All the
keyword arguments will override the current values. See
https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.search
for all available parameters.
| 146 | 160 |
def params(self, **kwargs):
"""
Specify query params to be used when executing the search. All the
keyword arguments will override the current values. See
https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.search
for all available parameters.
Example::
s = Search()
s = s.params(routing='user-1', preference='local')
"""
s = self._clone()
s._params.update(kwargs)
return s
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L146-L160
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 |
[] | 0 | true | 82.288828 | 15 | 1 | 100 | 9 |
def params(self, **kwargs):
s = self._clone()
s._params.update(kwargs)
return s
| 22,908 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request.index
|
(self, *index)
|
return s
|
Set the index for the search. If called empty it will remove all information.
Example:
s = Search()
s = s.index('twitter-2015.01.01', 'twitter-2015.01.02')
s = s.index(['twitter-2015.01.01', 'twitter-2015.01.02'])
|
Set the index for the search. If called empty it will remove all information.
| 162 | 188 |
def index(self, *index):
"""
Set the index for the search. If called empty it will remove all information.
Example:
s = Search()
s = s.index('twitter-2015.01.01', 'twitter-2015.01.02')
s = s.index(['twitter-2015.01.01', 'twitter-2015.01.02'])
"""
# .index() resets
s = self._clone()
if not index:
s._index = None
else:
indexes = []
for i in index:
if isinstance(i, str):
indexes.append(i)
elif isinstance(i, list):
indexes += i
elif isinstance(i, tuple):
indexes += list(i)
s._index = (self._index or []) + indexes
return s
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L162-L188
| 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 | 7 | 100 | 7 |
def index(self, *index):
# .index() resets
s = self._clone()
if not index:
s._index = None
else:
indexes = []
for i in index:
if isinstance(i, str):
indexes.append(i)
elif isinstance(i, list):
indexes += i
elif isinstance(i, tuple):
indexes += list(i)
s._index = (self._index or []) + indexes
return s
| 22,909 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request._resolve_field
|
(self, path)
| 190 | 196 |
def _resolve_field(self, path):
for dt in self._doc_type:
if not hasattr(dt, "_index"):
continue
field = dt._index.resolve_field(path)
if field is not None:
return field
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L190-L196
| 37 |
[
0,
1,
2,
4,
5,
6
] | 85.714286 |
[
3
] | 14.285714 | false | 82.288828 | 7 | 4 | 85.714286 | 0 |
def _resolve_field(self, path):
for dt in self._doc_type:
if not hasattr(dt, "_index"):
continue
field = dt._index.resolve_field(path)
if field is not None:
return field
| 22,910 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request._resolve_nested
|
(self, hit, parent_class=None)
|
return doc_class
| 198 | 216 |
def _resolve_nested(self, hit, parent_class=None):
doc_class = Hit
nested_path = []
nesting = hit["_nested"]
while nesting and "field" in nesting:
nested_path.append(nesting["field"])
nesting = nesting.get("_nested")
nested_path = ".".join(nested_path)
if hasattr(parent_class, "_index"):
nested_field = parent_class._index.resolve_field(nested_path)
else:
nested_field = self._resolve_field(nested_path)
if nested_field is not None:
return nested_field._doc_class
return doc_class
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L198-L216
| 37 |
[
0
] | 5.263158 |
[
1,
3,
4,
5,
6,
7,
8,
10,
11,
13,
15,
16,
18
] | 68.421053 | false | 82.288828 | 19 | 5 | 31.578947 | 0 |
def _resolve_nested(self, hit, parent_class=None):
doc_class = Hit
nested_path = []
nesting = hit["_nested"]
while nesting and "field" in nesting:
nested_path.append(nesting["field"])
nesting = nesting.get("_nested")
nested_path = ".".join(nested_path)
if hasattr(parent_class, "_index"):
nested_field = parent_class._index.resolve_field(nested_path)
else:
nested_field = self._resolve_field(nested_path)
if nested_field is not None:
return nested_field._doc_class
return doc_class
| 22,911 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request._get_result
|
(self, hit, parent_class=None)
|
return callback(hit)
| 218 | 240 |
def _get_result(self, hit, parent_class=None):
doc_class = Hit
dt = hit.get("_type")
if "_nested" in hit:
doc_class = self._resolve_nested(hit, parent_class)
elif dt in self._doc_type_map:
doc_class = self._doc_type_map[dt]
else:
for doc_type in self._doc_type:
if hasattr(doc_type, "_matches") and doc_type._matches(hit):
doc_class = doc_type
break
for t in hit.get("inner_hits", ()):
hit["inner_hits"][t] = Response(
self, hit["inner_hits"][t], doc_class=doc_class
)
callback = getattr(doc_class, "from_es", doc_class)
return callback(hit)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L218-L240
| 37 |
[
0,
1,
2,
3,
4,
6,
7,
8,
9,
11,
12,
15,
16,
20,
21,
22
] | 69.565217 |
[
5,
13,
14,
17
] | 17.391304 | false | 82.288828 | 23 | 7 | 82.608696 | 0 |
def _get_result(self, hit, parent_class=None):
doc_class = Hit
dt = hit.get("_type")
if "_nested" in hit:
doc_class = self._resolve_nested(hit, parent_class)
elif dt in self._doc_type_map:
doc_class = self._doc_type_map[dt]
else:
for doc_type in self._doc_type:
if hasattr(doc_type, "_matches") and doc_type._matches(hit):
doc_class = doc_type
break
for t in hit.get("inner_hits", ()):
hit["inner_hits"][t] = Response(
self, hit["inner_hits"][t], doc_class=doc_class
)
callback = getattr(doc_class, "from_es", doc_class)
return callback(hit)
| 22,912 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request.doc_type
|
(self, *doc_type, **kwargs)
|
return s
|
Set the type to search through. You can supply a single value or
multiple. Values can be strings or subclasses of ``Document``.
You can also pass in any keyword arguments, mapping a doc_type to a
callback that should be used instead of the Hit class.
If no doc_type is supplied any information stored on the instance will
be erased.
Example:
s = Search().doc_type('product', 'store', User, custom=my_callback)
|
Set the type to search through. You can supply a single value or
multiple. Values can be strings or subclasses of ``Document``.
| 242 | 266 |
def doc_type(self, *doc_type, **kwargs):
"""
Set the type to search through. You can supply a single value or
multiple. Values can be strings or subclasses of ``Document``.
You can also pass in any keyword arguments, mapping a doc_type to a
callback that should be used instead of the Hit class.
If no doc_type is supplied any information stored on the instance will
be erased.
Example:
s = Search().doc_type('product', 'store', User, custom=my_callback)
"""
# .doc_type() resets
s = self._clone()
if not doc_type and not kwargs:
s._doc_type = []
s._doc_type_map = {}
else:
s._doc_type.extend(doc_type)
s._doc_type.extend(kwargs.keys())
s._doc_type_map.update(kwargs)
return s
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L242-L266
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
20,
21,
22,
23,
24
] | 92 |
[
18,
19
] | 8 | false | 82.288828 | 25 | 3 | 92 | 12 |
def doc_type(self, *doc_type, **kwargs):
# .doc_type() resets
s = self._clone()
if not doc_type and not kwargs:
s._doc_type = []
s._doc_type_map = {}
else:
s._doc_type.extend(doc_type)
s._doc_type.extend(kwargs.keys())
s._doc_type_map.update(kwargs)
return s
| 22,913 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request.using
|
(self, client)
|
return s
|
Associate the search request with an elasticsearch client. A fresh copy
will be returned with current instance remaining unchanged.
:arg client: an instance of ``elasticsearch.Elasticsearch`` to use or
an alias to look up in ``elasticsearch_dsl.connections``
|
Associate the search request with an elasticsearch client. A fresh copy
will be returned with current instance remaining unchanged.
| 268 | 279 |
def using(self, client):
"""
Associate the search request with an elasticsearch client. A fresh copy
will be returned with current instance remaining unchanged.
:arg client: an instance of ``elasticsearch.Elasticsearch`` to use or
an alias to look up in ``elasticsearch_dsl.connections``
"""
s = self._clone()
s._using = client
return s
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L268-L279
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 82.288828 | 12 | 1 | 100 | 5 |
def using(self, client):
s = self._clone()
s._using = client
return s
| 22,914 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/search.py
|
Request.extra
|
(self, **kwargs)
|
return s
|
Add extra keys to the request body. Mostly here for backwards
compatibility.
|
Add extra keys to the request body. Mostly here for backwards
compatibility.
| 281 | 290 |
def extra(self, **kwargs):
"""
Add extra keys to the request body. Mostly here for backwards
compatibility.
"""
s = self._clone()
if "from_" in kwargs:
kwargs["from"] = kwargs.pop("from_")
s._extra.update(kwargs)
return s
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/search.py#L281-L290
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 |
[] | 0 | true | 82.288828 | 10 | 2 | 100 | 2 |
def extra(self, **kwargs):
s = self._clone()
if "from_" in kwargs:
kwargs["from"] = kwargs.pop("from_")
s._extra.update(kwargs)
return s
| 22,915 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.