Skip to content

Commit 3d88ee5

Browse files
unit tests
1 parent 7f6dc00 commit 3d88ee5

File tree

4 files changed

+1220
-731
lines changed

4 files changed

+1220
-731
lines changed

elasticsearch/dsl/document_base.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ def __mod__(self, value: Any) -> "InstrumentedExpression":
123123
def __rmod__(self, value: Any) -> "InstrumentedExpression":
124124
return InstrumentedExpression(f"{json.dumps(value)} % {self._expr}")
125125

126+
def where(
127+
self, expr: Union[str, "InstrumentedExpression"]
128+
) -> "InstrumentedExpression":
129+
"""Add a condition to be met for the row to be included.
130+
131+
Use only in expressions given in the ``STATS`` command.
132+
"""
133+
return InstrumentedExpression(f"{self._expr} WHERE {expr}")
134+
126135

127136
class InstrumentedField(InstrumentedExpression):
128137
"""Proxy object for a mapped document field.
@@ -170,15 +179,31 @@ def __neg__(self) -> str: # type: ignore[override]
170179
return f"-{self._expr}"
171180

172181
def asc(self) -> "InstrumentedField":
182+
"""Return the field name representation for ascending sort order.
183+
184+
For use in ES|QL queries only.
185+
"""
173186
return InstrumentedField(f"{self._expr} ASC", None)
174187

175188
def desc(self) -> "InstrumentedField":
189+
"""Return the field name representation for descending sort order.
190+
191+
For use in ES|QL queries only.
192+
"""
176193
return InstrumentedField(f"{self._expr} DESC", None)
177194

178195
def nulls_first(self) -> "InstrumentedField":
196+
"""Return the field name representation for nulls first sort order.
197+
198+
For use in ES|QL queries only.
199+
"""
179200
return InstrumentedField(f"{self._expr} NULLS FIRST", None)
180201

181202
def nulls_last(self) -> "InstrumentedField":
203+
"""Return the field name representation for nulls last sort order.
204+
205+
For use in ES|QL queries only.
206+
"""
182207
return InstrumentedField(f"{self._expr} NULLS LAST", None)
183208

184209
def __str__(self) -> str:

0 commit comments

Comments
 (0)