@@ -821,26 +821,30 @@ def admin_retrieval(
821
821
num_to_retrieve : int = NUM_RETURNED_HITS ,
822
822
offset : int = 0 ,
823
823
) -> list [InferenceChunkUncleaned ]:
824
- vespa_where_clauses = build_vespa_filters (filters , include_hidden = True )
825
- yql = (
826
- YQL_BASE .format (index_name = self .index_name )
827
- + vespa_where_clauses
828
- + '({grammar: "weakAnd"}userInput(@query) '
829
- # `({defaultIndex: "content_summary"}userInput(@query))` section is
830
- # needed for highlighting while the N-gram highlighting is broken /
831
- # not working as desired
832
- + f'or ({{defaultIndex: "{ CONTENT_SUMMARY } "}}userInput(@query)))'
824
+ vespa_where_clauses = build_vespa_filters (
825
+ filters , include_hidden = True , remove_trailing_and = True
833
826
)
827
+ yql = YQL_BASE .format (index_name = self .index_name ) + vespa_where_clauses
834
828
835
829
params : dict [str , str | int ] = {
836
830
"yql" : yql ,
837
- "query" : query ,
838
831
"hits" : num_to_retrieve ,
839
832
"offset" : 0 ,
840
833
"ranking.profile" : "admin_search" ,
841
834
"timeout" : VESPA_TIMEOUT ,
842
835
}
843
836
837
+ if len (query .strip ()) > 0 :
838
+ yql += (
839
+ ' and ({grammar: "weakAnd"}userInput(@query) '
840
+ # `({defaultIndex: "content_summary"}userInput(@query))` section is
841
+ # needed for highlighting while the N-gram highlighting is broken /
842
+ # not working as desired
843
+ + f'or ({{defaultIndex: "{ CONTENT_SUMMARY } "}}userInput(@query)))'
844
+ )
845
+ params ["yql" ] = yql
846
+ params ["query" ] = query
847
+
844
848
return query_vespa (params )
845
849
846
850
# Retrieves chunk information for a document:
0 commit comments