Class VectorQuery

java.lang.Object
com.azure.search.documents.models.VectorQuery
All Implemented Interfaces:
com.azure.json.JsonSerializable<VectorQuery>
Direct Known Subclasses:
VectorizableImageBinaryQuery, VectorizableImageUrlQuery, VectorizableTextQuery, VectorizedQuery

public class VectorQuery extends Object implements com.azure.json.JsonSerializable<VectorQuery>
The query parameters for vector and hybrid search queries.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of VectorQuery class.
  • Method Summary

    Modifier and Type
    Method
    Description
    fromJson(com.azure.json.JsonReader jsonReader)
    Reads an instance of VectorQuery from the JsonReader.
    Get the fields property: Vector Fields of type Collection(Edm.Single) to be included in the vector searched.
    Get the filterOverride property: The OData filter expression to apply to this specific vector query.
    Get the kind property: The kind of vector query being performed.
    Get the kNearestNeighborsCount property: Number of nearest neighbors to return as top hits.
    Get the oversampling property: Oversampling factor.
    Get the threshold property: The threshold used for vector queries.
    Get the weight property: Relative weight of the vector query when compared to other vector query and/or the text query within the same search request.
    Get the exhaustive property: When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index.
    setExhaustive(Boolean exhaustive)
    Set the exhaustive property: When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index.
    setFields(String... fields)
    Set the fields property: Vector Fields of type Collection(Edm.Single) to be included in the vector searched.
    setFilterOverride(String filterOverride)
    Set the filterOverride property: The OData filter expression to apply to this specific vector query.
    setKNearestNeighborsCount(Integer kNearestNeighborsCount)
    Set the kNearestNeighborsCount property: Number of nearest neighbors to return as top hits.
    setOversampling(Double oversampling)
    Set the oversampling property: Oversampling factor.
    Set the threshold property: The threshold used for vector queries.
    setWeight(Float weight)
    Set the weight property: Relative weight of the vector query when compared to other vector query and/or the text query within the same search request.
    com.azure.json.JsonWriter
    toJson(com.azure.json.JsonWriter jsonWriter)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.azure.json.JsonSerializable

    toJson, toJson, toJsonBytes, toJsonString
  • Constructor Details

    • VectorQuery

      public VectorQuery()
      Creates an instance of VectorQuery class.
  • Method Details

    • getKind

      public VectorQueryKind getKind()
      Get the kind property: The kind of vector query being performed.
      Returns:
      the kind value.
    • getKNearestNeighborsCount

      public Integer getKNearestNeighborsCount()
      Get the kNearestNeighborsCount property: Number of nearest neighbors to return as top hits.
      Returns:
      the kNearestNeighborsCount value.
    • setKNearestNeighborsCount

      public VectorQuery setKNearestNeighborsCount(Integer kNearestNeighborsCount)
      Set the kNearestNeighborsCount property: Number of nearest neighbors to return as top hits.
      Parameters:
      kNearestNeighborsCount - the kNearestNeighborsCount value to set.
      Returns:
      the VectorQuery object itself.
    • getFields

      public String getFields()
      Get the fields property: Vector Fields of type Collection(Edm.Single) to be included in the vector searched.
      Returns:
      the fields value.
    • setFields

      public VectorQuery setFields(String... fields)
      Set the fields property: Vector Fields of type Collection(Edm.Single) to be included in the vector searched.
      Parameters:
      fields - the fields value to set.
      Returns:
      the VectorQuery object itself.
    • isExhaustive

      public Boolean isExhaustive()
      Get the exhaustive property: When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index. Useful for scenarios where exact matches are critical, such as determining ground truth values.
      Returns:
      the exhaustive value.
    • setExhaustive

      public VectorQuery setExhaustive(Boolean exhaustive)
      Set the exhaustive property: When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index. Useful for scenarios where exact matches are critical, such as determining ground truth values.
      Parameters:
      exhaustive - the exhaustive value to set.
      Returns:
      the VectorQuery object itself.
    • getOversampling

      public Double getOversampling()
      Get the oversampling property: Oversampling factor. Minimum value is 1. It overrides the 'defaultOversampling' parameter configured in the index definition. It can be set only when 'rerankWithOriginalVectors' is true. This parameter is only permitted when a compression method is used on the underlying vector field.
      Returns:
      the oversampling value.
    • setOversampling

      public VectorQuery setOversampling(Double oversampling)
      Set the oversampling property: Oversampling factor. Minimum value is 1. It overrides the 'defaultOversampling' parameter configured in the index definition. It can be set only when 'rerankWithOriginalVectors' is true. This parameter is only permitted when a compression method is used on the underlying vector field.
      Parameters:
      oversampling - the oversampling value to set.
      Returns:
      the VectorQuery object itself.
    • getWeight

      public Float getWeight()
      Get the weight property: Relative weight of the vector query when compared to other vector query and/or the text query within the same search request. This value is used when combining the results of multiple ranking lists produced by the different vector queries and/or the results retrieved through the text query. The higher the weight, the higher the documents that matched that query will be in the final ranking. Default is 1.0 and the value needs to be a positive number larger than zero.
      Returns:
      the weight value.
    • setWeight

      public VectorQuery setWeight(Float weight)
      Set the weight property: Relative weight of the vector query when compared to other vector query and/or the text query within the same search request. This value is used when combining the results of multiple ranking lists produced by the different vector queries and/or the results retrieved through the text query. The higher the weight, the higher the documents that matched that query will be in the final ranking. Default is 1.0 and the value needs to be a positive number larger than zero.
      Parameters:
      weight - the weight value to set.
      Returns:
      the VectorQuery object itself.
    • getThreshold

      public VectorThreshold getThreshold()
      Get the threshold property: The threshold used for vector queries. Note this can only be set if all 'fields' use the same similarity metric.
      Returns:
      the threshold value.
    • setThreshold

      public VectorQuery setThreshold(VectorThreshold threshold)
      Set the threshold property: The threshold used for vector queries. Note this can only be set if all 'fields' use the same similarity metric.
      Parameters:
      threshold - the threshold value to set.
      Returns:
      the VectorQuery object itself.
    • getFilterOverride

      public String getFilterOverride()
      Get the filterOverride property: The OData filter expression to apply to this specific vector query. If no filter expression is defined at the vector level, the expression defined in the top level filter parameter is used instead.
      Returns:
      the filterOverride value.
    • setFilterOverride

      public VectorQuery setFilterOverride(String filterOverride)
      Set the filterOverride property: The OData filter expression to apply to this specific vector query. If no filter expression is defined at the vector level, the expression defined in the top level filter parameter is used instead.
      Parameters:
      filterOverride - the filterOverride value to set.
      Returns:
      the VectorQuery object itself.
    • toJson

      public com.azure.json.JsonWriter toJson(com.azure.json.JsonWriter jsonWriter) throws IOException
      Specified by:
      toJson in interface com.azure.json.JsonSerializable<VectorQuery>
      Throws:
      IOException
    • fromJson

      public static VectorQuery fromJson(com.azure.json.JsonReader jsonReader) throws IOException
      Reads an instance of VectorQuery from the JsonReader.
      Parameters:
      jsonReader - The JsonReader being read.
      Returns:
      An instance of VectorQuery if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.
      Throws:
      IOException - If an error occurs while reading the VectorQuery.