Send feedback
  
   
 
  
    
      Class NearestNeighborQuery (3.29.0)
    
    
       
    
    
      
      Stay organized with collections
     
    
      
      Save and categorize content based on your preferences.
     
    
  
      
     
  
  
   
  
    
  
  
    
    
    
  Version 3.29.0keyboard_arrow_down  
  
 
    
    
    
    
      
  
  
  
    
public   final   class  NearestNeighborQuery   extends   GeneratedMessageV3   implements   NearestNeighborQueryOrBuilder  
   
   A query to find a number of similar entities.
 Protobuf type google.cloud.aiplatform.v1beta1.NearestNeighborQuery
 
  
  
  
    Inherited Members 
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
      com.google.protobuf.GeneratedMessageV3.<ListT>makeMutableCopy(ListT) 
    
    
      com.google.protobuf.GeneratedMessageV3.<ListT>makeMutableCopy(ListT,int) 
    
    
    
    
    
    
    
    
      com.google.protobuf.GeneratedMessageV3.<T>emptyList(java.lang.Class<T>) 
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
   
  Static Fields
   
  
  
    
public   static   final   int   EMBEDDING_FIELD_NUMBER  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
  
  
    
public   static   final   int   ENTITY_ID_FIELD_NUMBER  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
  
  
    
public   static   final   int   NEIGHBOR_COUNT_FIELD_NUMBER  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
  
  
    
public   static   final   int   PARAMETERS_FIELD_NUMBER  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
  
  
    
public   static   final   int   PER_CROWDING_ATTRIBUTE_NEIGHBOR_COUNT_FIELD_NUMBER  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
  
  
    
public   static   final   int   STRING_FILTERS_FIELD_NUMBER  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
  Static Methods
   
   
  
  
    
public   static   NearestNeighborQuery   getDefaultInstance ()  
   
  
   
  
  
    
public   static   final   Descriptors . Descriptor   getDescriptor ()  
   
  
   
  
  
    
public   static   NearestNeighborQuery . Builder   newBuilder ()  
   
  
   
  
  
    
public   static   NearestNeighborQuery . Builder   newBuilder ( NearestNeighborQuery   prototype )  
   
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseDelimitedFrom ( InputStream   input )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseDelimitedFrom ( InputStream   input ,   ExtensionRegistryLite   extensionRegistry )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( byte []   data )  
   
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        data 
        byte [] 
       
     
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( byte []   data ,   ExtensionRegistryLite   extensionRegistry )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( ByteString   data )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( ByteString   data ,   ExtensionRegistryLite   extensionRegistry )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( CodedInputStream   input )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( CodedInputStream   input ,   ExtensionRegistryLite   extensionRegistry )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( InputStream   input )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( InputStream   input ,   ExtensionRegistryLite   extensionRegistry )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( ByteBuffer   data )  
   
  
  
  
   
  
  
    
public   static   NearestNeighborQuery   parseFrom ( ByteBuffer   data ,   ExtensionRegistryLite   extensionRegistry )  
   
  
  
  
   
  
  
    
public   static   Parser<NearestNeighborQuery>   parser ()  
   
  
  Methods
   
   
  
  
    
public   boolean   equals ( Object   obj )  
   
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        obj 
        Object  
       
     
  
  
  Overrides 
  
   
  
  
    
public   NearestNeighborQuery   getDefaultInstanceForType ()  
   
  
   
  
  
    
public   NearestNeighborQuery . Embedding   getEmbedding ()  
   
   Optional. The embedding vector that be used for similar search.
 
 .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.Embedding embedding = 2 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
   
  
  
    
public   NearestNeighborQuery . EmbeddingOrBuilder   getEmbeddingOrBuilder ()  
   
   Optional. The embedding vector that be used for similar search.
 
 .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.Embedding embedding = 2 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
   
  
  
    
public   String   getEntityId ()  
   
   Optional. The entity id whose similar entities should be searched for.
 If embedding is set, search will use embedding instead of
 entity_id.
 string entity_id = 1 [(.google.api.field_behavior) = OPTIONAL];
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        String  
        The entityId.
 
       
     
  
   
  
  
    
public   ByteString   getEntityIdBytes ()  
   
   Optional. The entity id whose similar entities should be searched for.
 If embedding is set, search will use embedding instead of
 entity_id.
 string entity_id = 1 [(.google.api.field_behavior) = OPTIONAL];
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        ByteString  
        The bytes for entityId.
 
       
     
  
   
  
  
    
public   NearestNeighborQuery . InstanceCase   getInstanceCase ()  
   
  
   
  
  
    
public   int   getNeighborCount ()  
   
   Optional. The number of similar entities to be retrieved from feature view
 for each query.
 int32 neighbor_count = 3 [(.google.api.field_behavior) = OPTIONAL];
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        int  
        The neighborCount.
 
       
     
  
   
  
  
    
public   NearestNeighborQuery . Parameters   getParameters ()  
   
   Optional. Parameters that can be set to tune query on the fly.
 
 .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.Parameters parameters = 7 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
   
  
  
    
public   NearestNeighborQuery . ParametersOrBuilder   getParametersOrBuilder ()  
   
   Optional. Parameters that can be set to tune query on the fly.
 
 .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.Parameters parameters = 7 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
   
  
  
    
public   Parser<NearestNeighborQuery>   getParserForType ()  
   
  
  Overrides 
  
   
  
  
    
public   int   getPerCrowdingAttributeNeighborCount ()  
   
   Optional. Crowding is a constraint on a neighbor list produced by nearest
 neighbor search requiring that no more than
 sper_crowding_attribute_neighbor_count of the k neighbors returned have the
 same value of crowding_attribute. It's used for improving result diversity.
 
 int32 per_crowding_attribute_neighbor_count = 5 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        int  
        The perCrowdingAttributeNeighborCount.
 
       
     
  
   
  
  
    
public   int   getSerializedSize ()  
   
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
  Overrides 
  
   
  
  
    
public   NearestNeighborQuery . StringFilter   getStringFilters ( int   index )  
   
   Optional. The list of string filters.
 
 repeated .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.StringFilter string_filters = 4 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        index 
        int  
       
     
  
  
   
  
  
    
public   int   getStringFiltersCount ()  
   
   Optional. The list of string filters.
 
 repeated .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.StringFilter string_filters = 4 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
   
  
  
    
public   List<NearestNeighborQuery . StringFilter >  getStringFiltersList ()  
   
   Optional. The list of string filters.
 
 repeated .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.StringFilter string_filters = 4 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
   
  
  
    
public   NearestNeighborQuery . StringFilterOrBuilder   getStringFiltersOrBuilder ( int   index )  
   
   Optional. The list of string filters.
 
 repeated .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.StringFilter string_filters = 4 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        index 
        int  
       
     
  
  
   
  
  
    
public   List <?   extends   NearestNeighborQuery . StringFilterOrBuilder >  getStringFiltersOrBuilderList ()  
   
   Optional. The list of string filters.
 
 repeated .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.StringFilter string_filters = 4 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        List <? extends com.google.cloud.aiplatform.v1beta1.NearestNeighborQuery.StringFilterOrBuilder > 
         
       
     
  
   
  
  
    
public   boolean   hasEmbedding ()  
   
   Optional. The embedding vector that be used for similar search.
 
 .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.Embedding embedding = 2 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        boolean  
        Whether the embedding field is set.
 
       
     
  
   
  
  
    
public   boolean   hasEntityId ()  
   
   Optional. The entity id whose similar entities should be searched for.
 If embedding is set, search will use embedding instead of
 entity_id.
 string entity_id = 1 [(.google.api.field_behavior) = OPTIONAL];
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        boolean  
        Whether the entityId field is set.
 
       
     
  
   
  
  
    
public   boolean   hasParameters ()  
   
   Optional. Parameters that can be set to tune query on the fly.
 
 .google.cloud.aiplatform.v1beta1.NearestNeighborQuery.Parameters parameters = 7 [(.google.api.field_behavior) = OPTIONAL];
 
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        boolean  
        Whether the parameters field is set.
 
       
     
  
   
  
  
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        int  
         
       
     
  
  Overrides 
  
   
  
  
    
protected   GeneratedMessageV3 . FieldAccessorTable   internalGetFieldAccessorTable ()  
   
  
  Overrides 
  
   
  
  
    
public   final   boolean   isInitialized ()  
   
  
  Overrides 
  
   
  
  
    
public   NearestNeighborQuery . Builder   newBuilderForType ()  
   
  
   
  
  
    
protected   NearestNeighborQuery . Builder   newBuilderForType ( GeneratedMessageV3 . BuilderParent   parent )  
   
  
  
  Overrides 
  
   
  
  
    
protected   Object   newInstance ( GeneratedMessageV3 . UnusedPrivateParameter   unused )  
   
  
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        Object  
         
       
     
  
  Overrides 
  
   
  
  
    
public   NearestNeighborQuery . Builder   toBuilder ()  
   
  
   
  
  
    
public   void   writeTo ( CodedOutputStream   output )  
   
  
  Overrides 
  
  
 
     
    
  
  
  
     
  
 
  
    
    
      
    
     
  
       
         
  
  
    
    Send feedback
  
   
 
       
    
    
  
  
 
  Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
  Last updated 2025-10-30 UTC.
 
 
  
  
    
    
    
      
  
  
    Need to tell us more?
  
   
 
     
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-30 UTC."],[],[]]