17
17
import com .azure .search .documents .models .QueryType ;
18
18
import com .azure .search .documents .models .ScoringStatistics ;
19
19
import com .azure .search .documents .models .SearchMode ;
20
- import com .azure .search .documents .models .SearchQueryVector ;
21
20
import com .azure .search .documents .models .SemanticErrorHandling ;
21
+ import com .azure .search .documents .models .VectorFilterMode ;
22
+ import com .azure .search .documents .models .VectorQuery ;
22
23
import java .io .IOException ;
23
24
import java .util .List ;
24
25
import java .util .Objects ;
@@ -110,14 +111,21 @@ public final class SearchRequest implements JsonSerializable<SearchRequest> {
110
111
*/
111
112
private String scoringProfile ;
112
113
114
+ /*
115
+ * Allows setting a separate search query that will be solely used for semantic reranking, semantic captions and
116
+ * semantic answers. Is useful for scenarios where there is a need to use different queries between the base
117
+ * retrieval and ranking phase, and the L2 semantic phase.
118
+ */
119
+ private String semanticQuery ;
120
+
113
121
/*
114
122
* The name of a semantic configuration that will be used when processing documents for queries of type semantic.
115
123
*/
116
124
private String semanticConfiguration ;
117
125
118
126
/*
119
- * Allows the user to choose whether a semantic call should fail completely (default / current behavior) , or to
120
- * return partial results .
127
+ * Allows the user to choose whether a semantic call should fail completely, or to return partial results
128
+ * (default) .
121
129
*/
122
130
private SemanticErrorHandling semanticErrorHandling ;
123
131
@@ -204,9 +212,15 @@ public final class SearchRequest implements JsonSerializable<SearchRequest> {
204
212
private String semanticFields ;
205
213
206
214
/*
207
- * The query parameters for multi-vector search queries.
215
+ * The query parameters for vector and hybrid search queries.
216
+ */
217
+ private List <VectorQuery > vectorQueries ;
218
+
219
+ /*
220
+ * Determines whether or not filters are applied before or after the vector search is performed. Default is
221
+ * 'preFilter'.
208
222
*/
209
- private List < SearchQueryVector > vectors ;
223
+ private VectorFilterMode vectorFilterMode ;
210
224
211
225
/** Creates an instance of SearchRequest class. */
212
226
public SearchRequest () {}
@@ -517,6 +531,30 @@ public SearchRequest setScoringProfile(String scoringProfile) {
517
531
return this ;
518
532
}
519
533
534
+ /**
535
+ * Get the semanticQuery property: Allows setting a separate search query that will be solely used for semantic
536
+ * reranking, semantic captions and semantic answers. Is useful for scenarios where there is a need to use different
537
+ * queries between the base retrieval and ranking phase, and the L2 semantic phase.
538
+ *
539
+ * @return the semanticQuery value.
540
+ */
541
+ public String getSemanticQuery () {
542
+ return this .semanticQuery ;
543
+ }
544
+
545
+ /**
546
+ * Set the semanticQuery property: Allows setting a separate search query that will be solely used for semantic
547
+ * reranking, semantic captions and semantic answers. Is useful for scenarios where there is a need to use different
548
+ * queries between the base retrieval and ranking phase, and the L2 semantic phase.
549
+ *
550
+ * @param semanticQuery the semanticQuery value to set.
551
+ * @return the SearchRequest object itself.
552
+ */
553
+ public SearchRequest setSemanticQuery (String semanticQuery ) {
554
+ this .semanticQuery = semanticQuery ;
555
+ return this ;
556
+ }
557
+
520
558
/**
521
559
* Get the semanticConfiguration property: The name of a semantic configuration that will be used when processing
522
560
* documents for queries of type semantic.
@@ -540,8 +578,8 @@ public SearchRequest setSemanticConfiguration(String semanticConfiguration) {
540
578
}
541
579
542
580
/**
543
- * Get the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely
544
- * (default / current behavior), or to return partial results.
581
+ * Get the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely,
582
+ * or to return partial results (default) .
545
583
*
546
584
* @return the semanticErrorHandling value.
547
585
*/
@@ -550,8 +588,8 @@ public SemanticErrorHandling getSemanticErrorHandling() {
550
588
}
551
589
552
590
/**
553
- * Set the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely
554
- * (default / current behavior), or to return partial results.
591
+ * Set the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely,
592
+ * or to return partial results (default) .
555
593
*
556
594
* @param semanticErrorHandling the semanticErrorHandling value to set.
557
595
* @return the SearchRequest object itself.
@@ -862,22 +900,44 @@ public SearchRequest setSemanticFields(String semanticFields) {
862
900
}
863
901
864
902
/**
865
- * Get the vectors property: The query parameters for multi-vector search queries.
903
+ * Get the vectorQueries property: The query parameters for vector and hybrid search queries.
904
+ *
905
+ * @return the vectorQueries value.
906
+ */
907
+ public List <VectorQuery > getVectorQueries () {
908
+ return this .vectorQueries ;
909
+ }
910
+
911
+ /**
912
+ * Set the vectorQueries property: The query parameters for vector and hybrid search queries.
913
+ *
914
+ * @param vectorQueries the vectorQueries value to set.
915
+ * @return the SearchRequest object itself.
916
+ */
917
+ public SearchRequest setVectorQueries (List <VectorQuery > vectorQueries ) {
918
+ this .vectorQueries = vectorQueries ;
919
+ return this ;
920
+ }
921
+
922
+ /**
923
+ * Get the vectorFilterMode property: Determines whether or not filters are applied before or after the vector
924
+ * search is performed. Default is 'preFilter'.
866
925
*
867
- * @return the vectors value.
926
+ * @return the vectorFilterMode value.
868
927
*/
869
- public List < SearchQueryVector > getVectors () {
870
- return this .vectors ;
928
+ public VectorFilterMode getVectorFilterMode () {
929
+ return this .vectorFilterMode ;
871
930
}
872
931
873
932
/**
874
- * Set the vectors property: The query parameters for multi-vector search queries.
933
+ * Set the vectorFilterMode property: Determines whether or not filters are applied before or after the vector
934
+ * search is performed. Default is 'preFilter'.
875
935
*
876
- * @param vectors the vectors value to set.
936
+ * @param vectorFilterMode the vectorFilterMode value to set.
877
937
* @return the SearchRequest object itself.
878
938
*/
879
- public SearchRequest setVectors ( List < SearchQueryVector > vectors ) {
880
- this .vectors = vectors ;
939
+ public SearchRequest setVectorFilterMode ( VectorFilterMode vectorFilterMode ) {
940
+ this .vectorFilterMode = vectorFilterMode ;
881
941
return this ;
882
942
}
883
943
@@ -898,6 +958,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
898
958
jsonWriter .writeArrayField (
899
959
"scoringParameters" , this .scoringParameters , (writer , element ) -> writer .writeString (element ));
900
960
jsonWriter .writeStringField ("scoringProfile" , this .scoringProfile );
961
+ jsonWriter .writeStringField ("semanticQuery" , this .semanticQuery );
901
962
jsonWriter .writeStringField ("semanticConfiguration" , this .semanticConfiguration );
902
963
jsonWriter .writeStringField ("semanticErrorHandling" , Objects .toString (this .semanticErrorHandling , null ));
903
964
jsonWriter .writeNumberField ("semanticMaxWaitInMilliseconds" , this .semanticMaxWaitInMilliseconds );
@@ -913,7 +974,8 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
913
974
jsonWriter .writeNumberField ("top" , this .top );
914
975
jsonWriter .writeStringField ("captions" , this .captions );
915
976
jsonWriter .writeStringField ("semanticFields" , this .semanticFields );
916
- jsonWriter .writeArrayField ("vectors" , this .vectors , (writer , element ) -> writer .writeJson (element ));
977
+ jsonWriter .writeArrayField ("vectorQueries" , this .vectorQueries , (writer , element ) -> writer .writeJson (element ));
978
+ jsonWriter .writeStringField ("vectorFilterMode" , Objects .toString (this .vectorFilterMode , null ));
917
979
return jsonWriter .writeEndObject ();
918
980
}
919
981
@@ -963,6 +1025,8 @@ public static SearchRequest fromJson(JsonReader jsonReader) throws IOException {
963
1025
deserializedSearchRequest .scoringParameters = scoringParameters ;
964
1026
} else if ("scoringProfile" .equals (fieldName )) {
965
1027
deserializedSearchRequest .scoringProfile = reader .getString ();
1028
+ } else if ("semanticQuery" .equals (fieldName )) {
1029
+ deserializedSearchRequest .semanticQuery = reader .getString ();
966
1030
} else if ("semanticConfiguration" .equals (fieldName )) {
967
1031
deserializedSearchRequest .semanticConfiguration = reader .getString ();
968
1032
} else if ("semanticErrorHandling" .equals (fieldName )) {
@@ -995,10 +1059,13 @@ public static SearchRequest fromJson(JsonReader jsonReader) throws IOException {
995
1059
deserializedSearchRequest .captions = reader .getString ();
996
1060
} else if ("semanticFields" .equals (fieldName )) {
997
1061
deserializedSearchRequest .semanticFields = reader .getString ();
998
- } else if ("vectors" .equals (fieldName )) {
999
- List <SearchQueryVector > vectors =
1000
- reader .readArray (reader1 -> SearchQueryVector .fromJson (reader1 ));
1001
- deserializedSearchRequest .vectors = vectors ;
1062
+ } else if ("vectorQueries" .equals (fieldName )) {
1063
+ List <VectorQuery > vectorQueries =
1064
+ reader .readArray (reader1 -> VectorQuery .fromJson (reader1 ));
1065
+ deserializedSearchRequest .vectorQueries = vectorQueries ;
1066
+ } else if ("vectorFilterMode" .equals (fieldName )) {
1067
+ deserializedSearchRequest .vectorFilterMode =
1068
+ VectorFilterMode .fromString (reader .getString ());
1002
1069
} else {
1003
1070
reader .skipChildren ();
1004
1071
}
0 commit comments