Skip to content

Commit

Permalink
Speed up property function
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Apr 23, 2024
1 parent 45abff6 commit 18620d2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions abcd/backends/atoms_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ def count(self, query: Union[dict, str, None] = None) -> int:
def property(self, name, query: Union[dict, str, None] = None) -> list:
"""
Gets all values of a specified property for matching documents in the
database. This method is very slow, so it is preferable to use
alternative methods where possible, such as count_property.
database. Alternative methods, such as count_property, may be faster.
Parameters
----------
Expand All @@ -551,15 +550,16 @@ def property(self, name, query: Union[dict, str, None] = None) -> list:
}

return [
hit["_source"][format(name)]
hit["fields"][format(name)][0]
for hit in helpers.scan(
self.client,
index=self.index_name,
query=query,
stored_fields=format(name),
_source=format(name),
_source=False,
stored_fields="_none_",
docvalue_fields=[format(name)],
)
if format(name) in hit["_source"]
if format(name) in hit["fields"]
]

def count_property(self, name, query: Union[dict, str, None] = None) -> dict:
Expand Down

0 comments on commit 18620d2

Please sign in to comment.