diff --git a/sample_project/querysets.py b/sample_project/querysets.py new file mode 100644 index 000000000..0803633bb --- /dev/null +++ b/sample_project/querysets.py @@ -0,0 +1,41 @@ +import os +from apis_core.utils.autocomplete import ( + ExternalAutocomplete, + TypeSenseAutocompleteAdapter, + LobidAutocompleteAdapter, +) + + +class PlaceExternalAutocomplete(ExternalAutocomplete): + adapters = [ + TypeSenseAutocompleteAdapter( + collections=[ + "prosnet-wikidata-place-index", + "prosnet-geonames-place-index", + ], + token=os.getenv("TYPESENSE_TOKEN", None), + server=os.getenv("TYPESENSE_SERVER", None), + ), + LobidAutocompleteAdapter( + params={ + "filter": "type:PlaceOrGeographicName", + "format": "json:preferredName", + } + ), + ] + + +class PersonExternalAutocomplete(ExternalAutocomplete): + adapters = [ + TypeSenseAutocompleteAdapter( + collections="prosnet-wikidata-person-index", + token=os.getenv("TYPESENSE_TOKEN", None), + server=os.getenv("TYPESENSE_SERVER", None), + ), + LobidAutocompleteAdapter( + params={ + "filter": "type:Person", + "format": "json:preferredName,professionOrOccupation", + } + ), + ]