Class: Google::Apis::DatastoreV1::FindNearest

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/datastore_v1/classes.rb,
lib/google/apis/datastore_v1/representations.rb,
lib/google/apis/datastore_v1/representations.rb
more...

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ FindNearest

Returns a new instance of FindNearest.

[View source]

704
705
706
# File 'lib/google/apis/datastore_v1/classes.rb', line 704

def initialize(**args)
   update!(**args)
end

Instance Attribute Details

#distance_measureString

Required. The Distance Measure to use, required. Corresponds to the JSON property distanceMeasure

Returns:

  • (String)

669
670
671
# File 'lib/google/apis/datastore_v1/classes.rb', line 669

def distance_measure
  @distance_measure
end

#distance_result_propertyString

Optional. Optional name of the field to output the result of the vector distance calculation. Must conform to entity property limitations. Corresponds to the JSON property distanceResultProperty

Returns:

  • (String)

675
676
677
# File 'lib/google/apis/datastore_v1/classes.rb', line 675

def distance_result_property
  @distance_result_property
end

#distance_thresholdFloat

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 Corresponds to the JSON property distanceThreshold

Returns:

  • (Float)

685
686
687
# File 'lib/google/apis/datastore_v1/classes.rb', line 685

def distance_threshold
  @distance_threshold
end

#limitFixnum

Required. The number of nearest neighbors to return. Must be a positive integer of no more than 100. Corresponds to the JSON property limit

Returns:

  • (Fixnum)

691
692
693
# File 'lib/google/apis/datastore_v1/classes.rb', line 691

def limit
  @limit
end

#query_vectorGoogle::Apis::DatastoreV1::Value

A message that can hold any of the supported value types and associated metadata. Corresponds to the JSON property queryVector


697
698
699
# File 'lib/google/apis/datastore_v1/classes.rb', line 697

def query_vector
  @query_vector
end

#vector_propertyGoogle::Apis::DatastoreV1::PropertyReference

A reference to a property relative to the kind expressions. Corresponds to the JSON property vectorProperty


702
703
704
# File 'lib/google/apis/datastore_v1/classes.rb', line 702

def vector_property
  @vector_property
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object

[View source]

709
710
711
712
713
714
715
716
# File 'lib/google/apis/datastore_v1/classes.rb', line 709

def update!(**args)
  @distance_measure = args[:distance_measure] if args.key?(:distance_measure)
  @distance_result_property = args[:distance_result_property] if args.key?(:distance_result_property)
  @distance_threshold = args[:distance_threshold] if args.key?(:distance_threshold)
  @limit = args[:limit] if args.key?(:limit)
  @query_vector = args[:query_vector] if args.key?(:query_vector)
  @vector_property = args[:vector_property] if args.key?(:vector_property)
end