Skip to content

Commit

Permalink
Add table data description to opensearch index
Browse files Browse the repository at this point in the history
Adds table data to the OpenSearch index for submission searching in the OpenSearch document enhancers.
  • Loading branch information
ItIsJordan committed Jan 12, 2024
1 parent b2c1a2a commit 4cf908a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hepdata/ext/opensearch/document_enhancers.py
Expand Up @@ -34,6 +34,7 @@
from hepdata.ext.opensearch.config.record_mapping import mapping as os_mapping
from hepdata.modules.permissions.models import SubmissionParticipant
from hepdata.modules.submission.api import get_latest_hepsubmission
from hepdata.modules.submission.models import DataSubmission

FORMATS = ['json', 'root', 'yaml', 'csv', 'yoda']

Expand Down Expand Up @@ -127,6 +128,18 @@ def add_data_keywords(doc):
doc['data_keywords'] = dict(agg_keywords)


def add_data_description(doc):
"""
Retrieve the description of the associated DataSubmission
object and add it to the doc for indexing.
:param doc: The document object
:return:
"""
submission = DataSubmission.query.filter_by(doi=doc["doi"]).one()
doc["description"] = submission.description


def add_data_abstract(doc):
"""
Adds the data abstract from its associated HEPSubmission to the document object
Expand Down Expand Up @@ -194,6 +207,7 @@ def enhance_data_document(doc):
add_data_table_urls(doc)
add_parent_publication(doc)
add_data_keywords(doc)
add_data_description(doc)


def enhance_publication_document(doc):
Expand Down

0 comments on commit 4cf908a

Please sign in to comment.