Skip to content
Snippets Groups Projects
Commit 5e75b202 authored by Nik | Klampfradler's avatar Nik | Klampfradler Committed by root
Browse files

Enable auto-query syntax in search bar

This allows exact matches with quotes and negation with -.
parent 2e4e8d04
No related branches found
No related tags found
1 merge request!204Resolve "Global search"
Checking pipeline status
......@@ -7,6 +7,7 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import ugettext_lazy as _
from django_tables2 import RequestConfig
from haystack.inputs import AutoQuery
from haystack.query import SearchQuerySet
from .decorators import admin_required, person_required
......@@ -328,7 +329,7 @@ def searchbar_snippets(request: HttpRequest) -> HttpResponse:
query = request.GET.get('q', '')
limit = int(request.GET.get('limit', '5'))
results = SearchQuerySet().autocomplete(text=query)[:limit]
results = SearchQuerySet().filter(text=AutoQuery(query))[:limit]
context = {"results": results}
return render(request, "search/searchbar_snippets.html", context)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment