Class: Google::Cloud::Firestore::V1::StructuredQuery::FindNearest
- Inherits:
-
Object
- Object
- Google::Cloud::Firestore::V1::StructuredQuery::FindNearest
- Extended by:
- Protobuf::MessageExts::ClassMethods
- Includes:
- Protobuf::MessageExts
- Defined in:
- proto_docs/google/firestore/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
-
#distance_measure ⇒ ::Google::Cloud::Firestore::V1::StructuredQuery::FindNearest::DistanceMeasure
Required.
-
#distance_result_field ⇒ ::String
Optional.
-
#distance_threshold ⇒ ::Google::Protobuf::DoubleValue
Optional.
-
#limit ⇒ ::Google::Protobuf::Int32Value
Required.
-
#query_vector ⇒ ::Google::Cloud::Firestore::V1::Value
Required.
-
#vector_field ⇒ ::Google::Cloud::Firestore::V1::StructuredQuery::FieldReference
Required.
Instance Attribute Details
#distance_measure ⇒ ::Google::Cloud::Firestore::V1::StructuredQuery::FindNearest::DistanceMeasure
Returns Required. The distance measure to use, required.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'proto_docs/google/firestore/v1/query.rb', line 407 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_field ⇒ ::String
Returns Optional. Optional name of the field to output the result of the vector distance calculation. Must conform to [document field name][google.firestore.v1.Document.fields] limitations.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'proto_docs/google/firestore/v1/query.rb', line 407 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.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'proto_docs/google/firestore/v1/query.rb', line 407 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 1000.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'proto_docs/google/firestore/v1/query.rb', line 407 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::Firestore::V1::Value
Returns Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'proto_docs/google/firestore/v1/query.rb', line 407 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_field ⇒ ::Google::Cloud::Firestore::V1::StructuredQuery::FieldReference
Required. An indexed vector field to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'proto_docs/google/firestore/v1/query.rb', line 407 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 |