Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions eland/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ def count(self, query_compiler: "QueryCompiler") -> pd.Series:
body = Query(query_params.query)
body.exists(field, must=True)

count_body = body.to_count_body()
if count_body is None:
raise ValueError("Invalid count query")
field_exists_count = query_compiler._client.count(
index=query_compiler._index_pattern, **body.to_count_body()
index=query_compiler._index_pattern, **count_body
)["count"]
counts[field] = field_exists_count

Expand Down Expand Up @@ -1350,8 +1353,11 @@ def index_count(self, query_compiler: "QueryCompiler", field: str) -> int:
body = Query(query_params.query)
body.exists(field, must=True)

count_body = body.to_count_body()
if count_body is None:
raise ValueError("Invalid count query")
count: int = query_compiler._client.count(
index=query_compiler._index_pattern, **body.to_count_body()
index=query_compiler._index_pattern, **count_body
)["count"]
return count

Expand Down Expand Up @@ -1388,8 +1394,11 @@ def index_matches_count(
else:
body.terms(field, items, must=True)

count_body = body.to_count_body()
if count_body is None:
raise ValueError("Invalid count query")
count: int = query_compiler._client.count(
index=query_compiler._index_pattern, **body.to_count_body()
index=query_compiler._index_pattern, **count_body
)["count"]
return count

Expand Down
Loading