diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-08-12 11:48:37 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-08-12 11:49:59 -0700 |
commit | f9853d3ae36f05c6f1ee803b0bb29d5eb5841bcf (patch) | |
tree | c02768af11f829fadcaaf4a25a4e7b639c0294ae /fatcat_scholar/search.py | |
parent | 7a53d66b346b7bd789f5b05832ffda08b160619c (diff) | |
download | fatcat-scholar-f9853d3ae36f05c6f1ee803b0bb29d5eb5841bcf.tar.gz fatcat-scholar-f9853d3ae36f05c6f1ee803b0bb29d5eb5841bcf.zip |
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
Diffstat (limited to 'fatcat_scholar/search.py')
-rw-r--r-- | fatcat_scholar/search.py | 9 |
1 files changed, 8 insertions, 1 deletions
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, |