diff options
Diffstat (limited to 'fatcat_scholar')
-rw-r--r-- | fatcat_scholar/search.py | 7 | ||||
-rw-r--r-- | fatcat_scholar/templates/base.html | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py index a0cad2c..2c02a58 100644 --- a/fatcat_scholar/search.py +++ b/fatcat_scholar/search.py @@ -31,6 +31,7 @@ from fatcat_scholar.query_citation import try_fuzzy_match class FulltextQuery(BaseModel): q: Optional[str] = None + parsed_q: Optional[str] = None limit: Optional[int] = None offset: Optional[int] = None filter_time: Optional[str] = None @@ -259,7 +260,7 @@ def process_query(query: FulltextQuery) -> FulltextHits: # fall through to regular query, with pre-parsing query = copy.copy(query) if query.q: - query.q = pre_parse_query(query.q) + query.parsed_q = pre_parse_query(query.q) return do_fulltext_search(query) @@ -301,7 +302,7 @@ def do_fulltext_search( # this query use the fancy built-in query string parser basic_fulltext = Q( "query_string", - query=query.q, + query=query.parsed_q or query.q, default_operator="AND", analyze_wildcard=True, allow_leading_wildcard=False, @@ -337,7 +338,7 @@ def do_fulltext_search( # simplified version of basic_fulltext query, for highlighting highlight_query = Q( - "query_string", query=query.q, default_operator="AND", lenient=True, + "query_string", query=query.parsed_q or query.q, default_operator="AND", lenient=True, ) search = search.highlight( "abstracts.body", diff --git a/fatcat_scholar/templates/base.html b/fatcat_scholar/templates/base.html index acdf15c..51af546 100644 --- a/fatcat_scholar/templates/base.html +++ b/fatcat_scholar/templates/base.html @@ -125,6 +125,9 @@ <div class="ui action input large fluid"> <input type="search" placeholder="{{ _("by title, authors, keywords...") }}" name="q" aria-label="{{ _('search for papers') }}" required itemprop="query-input" style="border-radius: 0; border: 1px #999 solid;" {% if query and query.q %}value="{{ query.q }}"{% endif %}> <button id="search_submit_button" class="ui green button" style="border-radius: 0; background-color: #44a25a; font-size: 1.2rem;">{{ _("Search") }}</button> + {% if query and query.parsed_q %} + <!-- parsed query: {{ query.parsed_q }} --> + {% endif %} </div> </div> </form> |