Description

The "Write To Collection" endpoint is used to write a set of operations to a collection. This RPC accepts a stream of operations and returns a steam of results, one result per operation.

Proto Definition


service BGSearch {
    rpc WriteToCollection (stream WriteToCollectionArgs) returns (stream WriteToCollectionResult) {}
}

Input Message

Name

stream WriteToCollectionArgs

Attributes

AttributeTypeDescription
requests(SetCollection | Insert | Remove | Update | Upsert)[]A list of operation to perform.

Each message that is streamed can have a list of operations. The operations must start with a SetCollection operation. All the subsequent operations are performed on the set collection until another SetCollection operation is performed.

Proto

message WriteToCollectionArgs {
  message SetCollection {
    string collection = 1; 
  }
  message Insert {
    IndexedGeometry geometry = 1; 
  }
  message Remove {
    GeometryID id = 1; 
  }
  message Update {
    IndexedGeometry geometry = 1; 
  }
  message Upsert {
    IndexedGeometry geometry = 1; 
  }
  message Request {
    oneof request {
      SetCollection set_collection = 1;
      Insert insert = 2;
      Remove remove = 3;
      Update update = 4;
      Upsert upsert = 5;
    }
  }
  repeated Request requests = 1;
}

Output Message

Name

stream WriteToCollectionResult

Attributes

AttributeTypeDescription
results(SetCollection | Insert | Remove | Update | Upsert)[]The results of the performed operations.

Each WriteToCollectionResult message streamed back has the same number of results as the number of requests in WriteToCollectionArgs.

Example

message WriteToCollectionResult {
  message CollectionSet {
  }
  message Insert {
    GeometryID id = 1;
  }
  message Remove {
    bool removed = 1;
  }
  message Update {
    bool updated = 1;
  }
  message Upsert {
    UpsertStatus status = 1;
  }
  message Result {
    oneof result {
      CollectionSet set_collection = 1;
      Insert insert = 2;
      Remove remove = 3;
      Update update = 4;
      Upsert upsert = 5;
    }
  }
  repeated Result results = 1;
}

Status Code

  • 5: NOT_FOUND if a collection with the provided name does not exist.
  • 0: OK if a collection is loaded successfully.