Class KnnFloatVectorQuery

    • Field Detail

      • NO_RESULTS

        private static final TopDocs NO_RESULTS
      • target

        private final float[] target
    • Constructor Detail

      • KnnFloatVectorQuery

        public KnnFloatVectorQuery​(java.lang.String field,
                                   float[] target,
                                   int k)
        Find the k nearest documents to the target vector according to the vectors in the given field. target vector.
        Parameters:
        field - a field that has been indexed as a KnnFloatVectorField.
        target - the target of the search
        k - the number of documents to find
        Throws:
        java.lang.IllegalArgumentException - if k is less than 1
      • KnnFloatVectorQuery

        public KnnFloatVectorQuery​(java.lang.String field,
                                   float[] target,
                                   int k,
                                   Query filter)
        Find the k nearest documents to the target vector according to the vectors in the given field. target vector.
        Parameters:
        field - a field that has been indexed as a KnnFloatVectorField.
        target - the target of the search
        k - the number of documents to find
        filter - a filter applied before the vector search
        Throws:
        java.lang.IllegalArgumentException - if k is less than 1
    • Method Detail

      • toString

        public java.lang.String toString​(java.lang.String field)
        Description copied from class: Query
        Prints a query to a string, with field assumed to be the default field and omitted.
        Specified by:
        toString in class Query
      • equals

        public boolean equals​(java.lang.Object o)
        Description copied from class: Query
        Override and implement query instance equivalence properly in a subclass. This is required so that QueryCache works properly.

        Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical to those of the other instance. Utility methods are provided for certain repetitive code.

        Overrides:
        equals in class AbstractKnnVectorQuery
        See Also:
        Query.sameClassAs(Object), Query.classHash()
      • getTargetCopy

        public float[] getTargetCopy()
        Returns:
        the target query vector of the search. Each vector element is a float.