Commit c02e9993 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update InspireHepStore.search_parameter to add parenthesis

parent 0df11386
......@@ -254,31 +254,42 @@ class InspirehepStore(BaseStore):
Args:
collection (str):
the collection in the store, *e.g.* ``LHCb Papers``.
the collection in the store:
* find cn d0 and tc p and not tc c
* find cc HAL Hidden a simpson, g and not tc c
* find cc HAL Hidden a g simpson and not tc c
* other syntax accept by inspirehep.net search engine
year_start (str):
select publication published for the given year
year_end (str):
select publication published between year_start and
year_end included.
Returns:
dict:
"""
query = collection
# add parenthesis
# see https://inspirehep.net/help/knowledge-base/inspire-paper-search/
if collection.startswith("find"):
collection = collection.replace("find ", "find (") + ")"
else:
collection = f"({collection})"
# add year(s) criteria
if year_start and not year_end:
query += f" and date {year_start}"
query = f"{collection} and date {year_start}"
elif not year_start and year_end:
query += f" and date {year_end}"
query = f"{collection} and date {year_end}"
elif year_start and year_end:
tpl = (f"date {el}" for el in range(year_start, year_end + 1))
sdates = " or ".join(tpl)
query += f" and ({sdates})"
query = f"{collection} and date {year_start}->{year_end}"
else:
query = collection
# get 100 records per page
# set the number of record to 100 per page
return dict(q=query, size=100)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment