@@ -101,18 +101,21 @@ protected QueryBuilder buildCombinedInferenceAndNonInferenceQuery(
101101 private QueryBuilder buildNestedQueryFromSparseVectorQuery (QueryBuilder queryBuilder , String searchInferenceId ) {
102102 assert (queryBuilder instanceof SparseVectorQueryBuilder );
103103 SparseVectorQueryBuilder sparseVectorQueryBuilder = (SparseVectorQueryBuilder ) queryBuilder ;
104+ SparseVectorQueryBuilder newSparseVectorQueryBuilder = new SparseVectorQueryBuilder (
105+ SemanticTextField .getEmbeddingsFieldName (sparseVectorQueryBuilder .getFieldName ()),
106+ sparseVectorQueryBuilder .getQueryVectors (),
107+ (sparseVectorQueryBuilder .getInferenceId () == null && sparseVectorQueryBuilder .getQuery () != null )
108+ ? searchInferenceId
109+ : sparseVectorQueryBuilder .getInferenceId (),
110+ sparseVectorQueryBuilder .getQuery (),
111+ sparseVectorQueryBuilder .shouldPruneTokens (),
112+ sparseVectorQueryBuilder .getTokenPruningConfig ()
113+ );
114+ newSparseVectorQueryBuilder .boost (sparseVectorQueryBuilder .boost ());
115+ newSparseVectorQueryBuilder .queryName (sparseVectorQueryBuilder .queryName ());
104116 return QueryBuilders .nestedQuery (
105117 SemanticTextField .getChunksFieldName (sparseVectorQueryBuilder .getFieldName ()),
106- new SparseVectorQueryBuilder (
107- SemanticTextField .getEmbeddingsFieldName (sparseVectorQueryBuilder .getFieldName ()),
108- sparseVectorQueryBuilder .getQueryVectors (),
109- (sparseVectorQueryBuilder .getInferenceId () == null && sparseVectorQueryBuilder .getQuery () != null )
110- ? searchInferenceId
111- : sparseVectorQueryBuilder .getInferenceId (),
112- sparseVectorQueryBuilder .getQuery (),
113- sparseVectorQueryBuilder .shouldPruneTokens (),
114- sparseVectorQueryBuilder .getTokenPruningConfig ()
115- ),
118+ newSparseVectorQueryBuilder ,
116119 ScoreMode .Max
117120 );
118121 }
0 commit comments