search: boost title value (#21025)
This commit is contained in:
parent
ba95fb474f
commit
2efc30d897
|
@ -1,6 +1,4 @@
|
|||
{% autoescape off %}
|
||||
{{object.title}}
|
||||
|
||||
{% for cell in object.get_cells %}
|
||||
{{ cell.render_for_search }}
|
||||
{% endfor %}
|
||||
|
|
|
@ -35,7 +35,8 @@ from django.views.decorators.csrf import csrf_exempt
|
|||
from django.utils.translation import ugettext as _
|
||||
from django.forms.widgets import Media
|
||||
|
||||
from haystack.query import SearchQuerySet
|
||||
from haystack.inputs import AutoQuery
|
||||
from haystack.query import SearchQuerySet, SQ
|
||||
|
||||
if 'mellon' in settings.INSTALLED_APPS:
|
||||
from mellon.utils import get_idps
|
||||
|
@ -405,8 +406,8 @@ def api_search(request):
|
|||
else:
|
||||
raise Http404()
|
||||
query = request.GET.get('q') or ''
|
||||
searchqueryset = SearchQuerySet()
|
||||
sqs = searchqueryset.auto_query(query).highlight()
|
||||
sqs = SearchQuerySet().filter(SQ(content=AutoQuery(query)) | SQ(title=AutoQuery(query)))
|
||||
sqs = sqs.highlight()
|
||||
sqs.load_all()
|
||||
hits = []
|
||||
for hit in sqs:
|
||||
|
|
|
@ -187,7 +187,6 @@ def test_search_contents_index():
|
|||
cell.save()
|
||||
|
||||
prepared_data = page_index.prepare(page)
|
||||
assert page.title in prepared_data['text']
|
||||
assert 'foobar' in prepared_data['text']
|
||||
|
||||
def test_search_api(app):
|
||||
|
|
Loading…
Reference in New Issue