From d0c2ffa8d8d070f9ef247c3c742a67b12d1bc16d Mon Sep 17 00:00:00 2001 From: Lingyin Wu Date: Tue, 5 Dec 2023 14:26:56 -0800 Subject: [PATCH] feat: update the v1 service definition to add numeric_restricts. PiperOrigin-RevId: 588189568 --- .../_protos/match_service.proto | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/google/cloud/aiplatform/matching_engine/_protos/match_service.proto b/google/cloud/aiplatform/matching_engine/_protos/match_service.proto index a56ff0fa3e..ae8bd8b21c 100644 --- a/google/cloud/aiplatform/matching_engine/_protos/match_service.proto +++ b/google/cloud/aiplatform/matching_engine/_protos/match_service.proto @@ -42,6 +42,9 @@ message MatchRequest { // The list of restricts. repeated Namespace restricts = 4; + //The list of numeric restricts. + repeated NumericNamespace numeric_restricts = 11; + // Crowding is a constraint on a neighbor list produced by nearest neighbor // search requiring that no more than some value k' of the k neighbors // returned have the same value of crowding_attribute. @@ -88,6 +91,9 @@ message Embedding { // The list of restricts. repeated Namespace restricts = 3; + // The list of numeric restricts. + repeated NumericNamespace numeric_restricts = 5; + // The attribute value used for crowding. The maximum number of neighbors // to return per crowding attribute value // (per_crowding_attribute_num_neighbors) is configured per-query. @@ -175,6 +181,7 @@ message BatchMatchResponse { // Namespace specifies the rules for determining the datapoints that are // eligible for each matching query, overall query is an AND across namespaces. +// This uses categorical tokens. message Namespace { // The string name of the namespace that this proto is specifying, // such as "color", "shape", "geo", or "tags". @@ -192,4 +199,53 @@ message Namespace { // query will match datapoints that are red or blue, but if those points are // also purple, then they will be excluded even if they are red/blue. repeated string deny_tokens = 3; -} \ No newline at end of file +} + +// NumericNamespace specifies the rules for determining the datapoints that are +// eligible for each matching query, overall query is an AND across namespaces. +// This uses numeric comparisons. +message NumericNamespace { + + // The string name of the namespace that this proto is specifying, + // such as "size" or "cost". + string name = 1; + + // The type of Value must be consistent for all datapoints with a given + // namespace name. This is verified at runtime. + oneof Value { + // Represents 64 bit integer. + int64 value_int = 2; + // Represents 32 bit float. + float value_float = 3; + // Represents 64 bit float. + double value_double = 4; + } + + // Which comparison operator to use. Should be specified for queries only; + // specifying this for a datapoint is an error. + // + // Datapoints for which Operator is true relative to the query's Value + // field will be allowlisted. + enum Operator { + // Default value of the enum. + OPERATOR_UNSPECIFIED = 0; + + // Datapoints are eligible iff their value is < the query's. + LESS = 1; + + // Datapoints are eligible iff their value is <= the query's. + LESS_EQUAL = 2; + + // Datapoints are eligible iff their value is == the query's. + EQUAL = 3; + + // Datapoints are eligible iff their value is >= the query's. + GREATER_EQUAL = 4; + + // Datapoints are eligible iff their value is > the query's. + GREATER = 5; + } + + // Which comparison operator to use. + Operator op = 5; +}