From f9853d3ae36f05c6f1ee803b0bb29d5eb5841bcf Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 12 Aug 2020 11:48:37 -0700 Subject: search: use simplified query for highlighting This fixes broken phrase query highlighting. I found this issues but it may have been unrelated: https://github.com/elastic/elasticsearch/issues/40227 --- fatcat_scholar/search.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py index c362ea6..b4ec472 100644 --- a/fatcat_scholar/search.py +++ b/fatcat_scholar/search.py @@ -217,12 +217,19 @@ def do_fulltext_search( "boosting", positive=base_query, negative=poor_metadata, negative_boost=0.5, ) + # simplified version of basic_fulltext query, for highlighting + highlight_query= Q( + "query_string", + query=query.q, + default_operator="AND", + lenient=True, + ) search = search.highlight( "abstracts.body", "fulltext.body", "fulltext.acknowledgement", "fulltext.annex", - highlight_query=basic_fulltext.to_dict(), + highlight_query=highlight_query.to_dict(), require_field_match=False, number_of_fragments=2, fragment_size=300, -- cgit v1.2.3