Class VectorQuery

java.lang.Object
org.ametys.plugins.ai.search.VectorQuery
All Implemented Interfaces:
Query

public class VectorQuery extends Object implements Query
An embedding-based query, which can be used to perform a vector search (solr knn query).
  • Constructor Details

    • VectorQuery

      public VectorQuery(String fieldName, List<Float> vector)
      Create a vector query with the given field name and vector, and a default of minReturn of 0.7.
      Parameters:
      fieldName - the name of the field to search on
      vector - the vector to search with
    • VectorQuery

      public VectorQuery(String fieldName, List<Float> vector, double minReturn)
      Create a vector query with the given field name and vector, and a default topK of 10.
      Parameters:
      fieldName - the name of the field to search on
      vector - the vector to search with
      minReturn - the min return value for the vector similarity query (between 0 and 1, default is 0.7)
  • Method Details

    • build

      Description copied from interface: Query
      Build the solr query string representing the Query object.
      Specified by:
      build in interface Query
      Returns:
      the solr query string representing the Query object.
      Throws:
      QuerySyntaxException - if the query can't be built because of a syntax error.
    • buildAsJson

      Description copied from interface: Query
      Build the solr query representing the Query object.
      The return type may be either String or Map<String, Object> following the Solr JSON Query DSL.
      Specified by:
      buildAsJson in interface Query
      Returns:
      the solr query representing the Query object. Can be empty in case of empty query.
      Throws:
      QuerySyntaxException - if the query can't be built because of a syntax error.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object