Skip to content

Commit

Permalink
fix(sample_project): add autocomplete querysets for person and place
Browse files Browse the repository at this point in the history
Closes: #900
  • Loading branch information
b1rger committed Jul 30, 2024
1 parent e8de605 commit 8d6d8dd
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions sample_project/querysets.py
Original file line number Diff line number Diff line change
@@ -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",
}
),
]

0 comments on commit 8d6d8dd

Please sign in to comment.