Skip to content

Commit

Permalink
Use term filter instead of match for exact keyword matches when findi…
Browse files Browse the repository at this point in the history
…ng grid data uuids in elastic search (equinor#681)
  • Loading branch information
HansKallekleiv authored Aug 2, 2024
1 parent 0a37bf7 commit 1604fa3
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions backend_py/primary/primary/services/sumo_access/queries/grid3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,30 @@ async def get_grid_geometry_and_property_blob_ids_async(
{
"bool": {
"must": [
{"match": {"_sumo.parent_object.keyword": case_id}},
{"match": {"class": "cpgrid"}},
{"match": {"fmu.iteration.name": iteration}},
{"match": {"fmu.realization.id": realization}},
{"match": {"data.name.keyword": grid_name}},
{"term": {"_sumo.parent_object.keyword": case_id}},
{"term": {"class.keyword": "cpgrid"}},
{"term": {"fmu.iteration.name.keyword": iteration}},
{"term": {"fmu.realization.id": realization}},
{"term": {"data.name.keyword": grid_name}},
]
}
},
{
"bool": {
"must": [
{"match": {"_sumo.parent_object.keyword": case_id}},
{"match": {"class": "cpgrid_property"}},
{"match": {"fmu.iteration.name": iteration}},
{"match": {"fmu.realization.id": realization}},
{"match": {"data.name.keyword": parameter_name}},
{"match": {"data.tagname.keyword": grid_name}},
{"term": {"_sumo.parent_object.keyword": case_id}},
{"term": {"class.keyword": "cpgrid_property"}},
{"term": {"fmu.iteration.name.keyword": iteration}},
{"term": {"fmu.realization.id": realization}},
{"term": {"data.name.keyword": parameter_name}},
{"term": {"data.tagname.keyword": grid_name}},
]
}
},
],
"minimum_should_match": 1,
}
}

time_filter = get_time_filter(parameter_time_or_interval_str)

if time_filter.time_type != TimeType.NONE:
Expand All @@ -118,7 +117,6 @@ async def get_grid_geometry_and_property_blob_ids_async(

result = response.json()
hits = result["hits"]["hits"]

if len(hits) != 2:
raise InvalidDataError(f"Expected 2 hits, got {len(hits)}", service=Service.SUMO)

Expand Down

0 comments on commit 1604fa3

Please sign in to comment.