Content Search¶
iiisight can discover a resource’s Content Search
service, run a query, and return the hits as annotations in the normalized model.
It handles both Content Search 2.0 (AnnotationPage responses) and the older 1.0
(sc:AnnotationList, upgraded automatically).
Searching¶
Pass a manifest (its search service is discovered), a Service,
or a search base URL:
async with iiisight.AsyncClient() as client:
manifest = await client.fetch_manifest(url)
page = await client.search(manifest, "cathedral")
for hit in page.items:
print(hit.target, hit.body)
with iiisight.Client() as client:
manifest = client.fetch_manifest(url)
page = client.search(manifest, "cathedral")
for hit in page.items:
print(hit.target, hit.body)
The result is an AnnotationPage; each hit is an
Annotation whose target points into the object (often with an
xywh fragment) and whose body carries the matched text.
Extra parameters¶
Content Search supports parameters like motivation, date, and user:
page = await client.search(manifest, "cathedral", params={"motivation": "painting"})
Discovering the service yourself¶
service = iiisight.find_search_service(manifest) # -> Service | None
if service:
url = iiisight.search_url(service, "cathedral")
# ... fetch `url` however you like, then:
# page = iiisight.parse_search_response(response_json)