Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace direct id-based search with a query for the id #11370

Closed
wants to merge 3 commits into from
Closed
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
26 changes: 20 additions & 6 deletions arches/app/models/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,9 +1648,14 @@ def delete_index(self):
query.delete(index=CONCEPTS_INDEX)

def get_scheme_id(self):
result = se.search(index=CONCEPTS_INDEX, id=self.id)
if result["found"]:
return Concept(result["top_concept"])
query = Query(se=se, start=0, limit=100)
bool_query = Bool()
bool_query.filter(Term(field="id", term=self.id))
query.add_query(bool_query)
results = query.search(index=CONCEPTS_INDEX)

if len(results["hits"]["hits"]):
return Concept(results["hits"]["hits"][0]["_source"]["top_concept"])
else:
return None

Expand Down Expand Up @@ -1723,6 +1728,15 @@ def exact_val_match(val, conceptid=None):


def get_preflabel_from_valueid(valueid, lang):
concept_label = se.search(index=CONCEPTS_INDEX, id=valueid)
if concept_label["found"]:
return get_preflabel_from_conceptid(concept_label["_source"]["conceptid"], lang)
query = Query(se=se, start=0, limit=100)
bool_query = Bool()
bool_query.filter(Term(field="id", term=valueid))
query.add_query(bool_query)
results = query.search(index=CONCEPTS_INDEX)

if len(results["hits"]["hits"]):
return get_preflabel_from_conceptid(
results["hits"]["hits"][0]["_source"]["conceptid"], lang
)
else:
return None
Loading