Skip to content

Commit

Permalink
Ensure index added to es query ops
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed May 3, 2021
1 parent 55350af commit e6553e8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/mp_api/routes/electronic_structure/query_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def query(

return {"criteria": crit}

def ensure_indexes(self):

keys = ["band_gap", "efermi", "magnetic_ordering", "is_gap_direct", "is_metal"]

return [(key, False) for key in keys]


class BSDataQuery(QueryOperator):
"""
Expand Down Expand Up @@ -131,6 +137,16 @@ def query(

return {"criteria": crit}

def ensure_indexes(self):

keys = ["bandstructure"]

for bs_type in BSPathType:
for field in ["band_gap", "efermi"]:
keys.append(f"bandstructure.{bs_type.value}.{field}")

return [(key, False) for key in keys]


class DOSDataQuery(QueryOperator):
"""
Expand Down Expand Up @@ -225,3 +241,12 @@ def query(
crit.update({"dos.magnetic_ordering": magnetic_ordering.value})

return {"criteria": crit}

def ensure_indexes(self):

keys = ["dos", "dos.magnetic_ordering"]

for proj_type in DOSProjectionType:
keys.append(f"dos.{proj_type.value}.$**")

return [(key, False) for key in keys]

0 comments on commit e6553e8

Please sign in to comment.