You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Models that subclass wagtail.search.index.Indexed very often have the optimal search matching criteria / weighting configured on the model using the search_fields attribute.
If using one of these models with AutocompletePanel, it's difficult to imagine a scenario where you wouldn't just want to reuse this configuration for an admin-facing search too. This would be possible with something like:
from wagtail.search.index import Indexed
from wagtail.search.backends import get_search_backend
@require_POST
def search(request):
...
if issubclass(model, Indexed):
backend = get_search_backend()
try:
matches = backend.autocomplete(search_query, model)
except NotImplementedError:
matches = backend.search(search_query, model)
else:
# continue with existing behaviour
The text was updated successfully, but these errors were encountered:
Models that subclass
wagtail.search.index.Indexed
very often have the optimal search matching criteria / weighting configured on the model using thesearch_fields
attribute.If using one of these models with
AutocompletePanel
, it's difficult to imagine a scenario where you wouldn't just want to reuse this configuration for an admin-facing search too. This would be possible with something like:The text was updated successfully, but these errors were encountered: