Skip to content

Highlighting search terms - empty outcome #112

@fmvalentino

Description

@fmvalentino

Dear dev team,

I'm trying to reproduce the query to fetch snippets of text shown in the Search_API_Python.ipynb notebook. The search returns papers, but the 'highlighting' section is systematically empty. I checked by hand that the searched words are in at least some of the papers.

Could you help me figure this out?

import requests
from urllib.parse import urlencode, quote_plus

# Here below ADS_TOKEN is my own 
encoded_query = urlencode({"q": "body:('transiting exoplanets' +JWST)",
                           "fl": "title,id",
                           "rows": 3,
                           "sort": "score desc",
                           "hl": "true",
                           "hl.fl": "body",
                           "hl.snippets": 2,
                           "hl.fragsize": 100
                          })
results = requests.get("https://api.adsabs.harvard.edu/v1/search/query?{}".format(encoded_query), \
                       headers={'Authorization': 'Bearer ' + ADS_TOKEN})

results.json()

Output:

{'responseHeader': {'status': 0,
  'QTime': 1005,
  'params': {'hl': 'true',
   'fl': 'title,id,publisher',
   'hl.fragsize': '100',
   'start': '0',
   'sort': 'score desc',
   'rows': '3',
   'hl.maxHighlightCharacters': '100',
   'hl.snippets': '2',
   'q': "body:('transiting exoplanets' +JWST)",
   'hl.q': "body:('transiting exoplanets' +JWST)",
   'internal_logging_params': 'X-Amzn-Trace-Id=Root=1-69c3ed3b-53492c956382949216dd2d93',
   'hl.fl': 'body',
   'wt': 'json'}},
 'response': {'numFound': 5540,
  'start': 0,
  'numFoundExact': True,
  'docs': [{'id': '20116449',
    'title': ['Detectability of Artificial Lights from Proxima b']},
   {'id': '1093212',
    'title': ['Transiting Exoplanet Survey Satellite (TESS)']},
   {'id': '34038913',
    'title': ['The PLATO mission'],
    'publisher': 'Springer'}]},
 'highlighting': {'20116449': {}, '1093212': {}, '34038913': {}},
 'filtered': 'true'}

python 3.12.11, requests 2.32.5

Thank you in advance for your help!
Francesco

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions