Class: Google::Cloud::Datastore::V1::FindNearest

Inherits:
Object
  • Object
show all
Extended by:
Protobuf::MessageExts::ClassMethods
Includes:
Protobuf::MessageExts
Defined in:
proto_docs/google/datastore/v1/query.rb

Overview

Nearest Neighbors search config. The ordering provided by FindNearest supersedes the order_by stage. If multiple documents have the same vector distance, the returned document order is not guaranteed to be stable between queries.

Defined Under Namespace

Modules: DistanceMeasure

Instance Attribute Summary collapse

Instance Attribute Details

#distance_measure::Google::Cloud::Datastore::V1::FindNearest::DistanceMeasure

Returns Required. The Distance Measure to use, required.

Returns:



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'proto_docs/google/datastore/v1/query.rb', line 512

class FindNearest
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # The distance measure to use when comparing vectors.
  module DistanceMeasure
    # Should not be set.
    DISTANCE_MEASURE_UNSPECIFIED = 0

    # Measures the EUCLIDEAN distance between the vectors. See
    # [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
    # more. The resulting distance decreases the more similar two vectors are.
    EUCLIDEAN = 1

    # COSINE distance compares vectors based on the angle between them, which
    # allows you to measure similarity that isn't based on the vectors
    # magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
    # instead of COSINE distance, which is mathematically equivalent with
    # better performance. See [Cosine
    # Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
    # more about COSINE similarity and COSINE distance. The resulting COSINE
    # distance decreases the more similar two vectors are.
    COSINE = 2

    # Similar to cosine but is affected by the magnitude of the vectors. See
    # [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
    # The resulting distance increases the more similar two vectors are.
    DOT_PRODUCT = 3
  end
end

#distance_result_property::String

Returns Optional. Optional name of the field to output the result of the vector distance calculation. Must conform to [entity property][google.datastore.v1.Entity.properties] limitations.

Returns:

  • (::String)

    Optional. Optional name of the field to output the result of the vector distance calculation. Must conform to [entity property][google.datastore.v1.Entity.properties] limitations.



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'proto_docs/google/datastore/v1/query.rb', line 512

class FindNearest
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # The distance measure to use when comparing vectors.
  module DistanceMeasure
    # Should not be set.
    DISTANCE_MEASURE_UNSPECIFIED = 0

    # Measures the EUCLIDEAN distance between the vectors. See
    # [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
    # more. The resulting distance decreases the more similar two vectors are.
    EUCLIDEAN = 1

    # COSINE distance compares vectors based on the angle between them, which
    # allows you to measure similarity that isn't based on the vectors
    # magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
    # instead of COSINE distance, which is mathematically equivalent with
    # better performance. See [Cosine
    # Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
    # more about COSINE similarity and COSINE distance. The resulting COSINE
    # distance decreases the more similar two vectors are.
    COSINE = 2

    # Similar to cosine but is affected by the magnitude of the vectors. See
    # [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
    # The resulting distance increases the more similar two vectors are.
    DOT_PRODUCT = 3
  end
end

#distance_threshold::Google::Protobuf::DoubleValue

Returns Optional. Option to specify a threshold for which no less similar documents will be returned. The behavior of the specified distance_measure will affect the meaning of the distance threshold. Since DOT_PRODUCT distances increase when the vectors are more similar, the comparison is inverted.

For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold For DOT_PRODUCT: WHERE distance >= distance_threshold.

Returns:

  • (::Google::Protobuf::DoubleValue)

    Optional. Option to specify a threshold for which no less similar documents will be returned. The behavior of the specified distance_measure will affect the meaning of the distance threshold. Since DOT_PRODUCT distances increase when the vectors are more similar, the comparison is inverted.

    For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold For DOT_PRODUCT: WHERE distance >= distance_threshold



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'proto_docs/google/datastore/v1/query.rb', line 512

class FindNearest
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # The distance measure to use when comparing vectors.
  module DistanceMeasure
    # Should not be set.
    DISTANCE_MEASURE_UNSPECIFIED = 0

    # Measures the EUCLIDEAN distance between the vectors. See
    # [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
    # more. The resulting distance decreases the more similar two vectors are.
    EUCLIDEAN = 1

    # COSINE distance compares vectors based on the angle between them, which
    # allows you to measure similarity that isn't based on the vectors
    # magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
    # instead of COSINE distance, which is mathematically equivalent with
    # better performance. See [Cosine
    # Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
    # more about COSINE similarity and COSINE distance. The resulting COSINE
    # distance decreases the more similar two vectors are.
    COSINE = 2

    # Similar to cosine but is affected by the magnitude of the vectors. See
    # [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
    # The resulting distance increases the more similar two vectors are.
    DOT_PRODUCT = 3
  end
end

#limit::Google::Protobuf::Int32Value

Returns Required. The number of nearest neighbors to return. Must be a positive integer of no more than 100.

Returns:



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'proto_docs/google/datastore/v1/query.rb', line 512

class FindNearest
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # The distance measure to use when comparing vectors.
  module DistanceMeasure
    # Should not be set.
    DISTANCE_MEASURE_UNSPECIFIED = 0

    # Measures the EUCLIDEAN distance between the vectors. See
    # [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
    # more. The resulting distance decreases the more similar two vectors are.
    EUCLIDEAN = 1

    # COSINE distance compares vectors based on the angle between them, which
    # allows you to measure similarity that isn't based on the vectors
    # magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
    # instead of COSINE distance, which is mathematically equivalent with
    # better performance. See [Cosine
    # Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
    # more about COSINE similarity and COSINE distance. The resulting COSINE
    # distance decreases the more similar two vectors are.
    COSINE = 2

    # Similar to cosine but is affected by the magnitude of the vectors. See
    # [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
    # The resulting distance increases the more similar two vectors are.
    DOT_PRODUCT = 3
  end
end

#query_vector::Google::Cloud::Datastore::V1::Value

Returns Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.

Returns:



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'proto_docs/google/datastore/v1/query.rb', line 512

class FindNearest
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # The distance measure to use when comparing vectors.
  module DistanceMeasure
    # Should not be set.
    DISTANCE_MEASURE_UNSPECIFIED = 0

    # Measures the EUCLIDEAN distance between the vectors. See
    # [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
    # more. The resulting distance decreases the more similar two vectors are.
    EUCLIDEAN = 1

    # COSINE distance compares vectors based on the angle between them, which
    # allows you to measure similarity that isn't based on the vectors
    # magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
    # instead of COSINE distance, which is mathematically equivalent with
    # better performance. See [Cosine
    # Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
    # more about COSINE similarity and COSINE distance. The resulting COSINE
    # distance decreases the more similar two vectors are.
    COSINE = 2

    # Similar to cosine but is affected by the magnitude of the vectors. See
    # [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
    # The resulting distance increases the more similar two vectors are.
    DOT_PRODUCT = 3
  end
end

#vector_property::Google::Cloud::Datastore::V1::PropertyReference

Required. An indexed vector property to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.

Returns:



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'proto_docs/google/datastore/v1/query.rb', line 512

class FindNearest
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # The distance measure to use when comparing vectors.
  module DistanceMeasure
    # Should not be set.
    DISTANCE_MEASURE_UNSPECIFIED = 0

    # Measures the EUCLIDEAN distance between the vectors. See
    # [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
    # more. The resulting distance decreases the more similar two vectors are.
    EUCLIDEAN = 1

    # COSINE distance compares vectors based on the angle between them, which
    # allows you to measure similarity that isn't based on the vectors
    # magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
    # instead of COSINE distance, which is mathematically equivalent with
    # better performance. See [Cosine
    # Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
    # more about COSINE similarity and COSINE distance. The resulting COSINE
    # distance decreases the more similar two vectors are.
    COSINE = 2

    # Similar to cosine but is affected by the magnitude of the vectors. See
    # [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
    # The resulting distance increases the more similar two vectors are.
    DOT_PRODUCT = 3
  end
end