Files
services/search/proto/search.proto
2022-01-07 09:58:10 +00:00

88 lines
2.0 KiB
Protocol Buffer

syntax = "proto3";
import "google/protobuf/struct.proto";
package search;
option go_package = "./proto;search";
service Search {
// TODO reinstate when we have a reason for more fine grained control of index creation, for now just rely on lazy creation on first index call
// rpc CreateIndex(CreateIndexRequest) returns (CreateIndexResponse) {}
rpc Index(IndexRequest) returns (IndexResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
rpc Search(SearchRequest) returns (SearchResponse) {}
rpc DeleteIndex(DeleteIndexRequest) returns (DeleteIndexResponse) {}
}
// Index a document i.e. insert a document to search for.
message IndexRequest {
// The document to index
Document document = 1;
// The index this document belongs to
string index = 2;
}
message Document {
// The ID for this document. If blank, one will be generated
string id = 1;
// The JSON contents of the document
google.protobuf.Struct contents = 2;
}
message IndexResponse {
string id = 1;
}
// Delete a document given its ID
message DeleteRequest {
// The ID of the document to delete
string id = 1;
// The index the document belongs to
string index = 2;
}
message DeleteResponse {}
// Search for documents in a given in index
message SearchRequest {
// The index the document belongs to
string index = 1;
// The query. See docs for query language examples
string query = 2;
}
message SearchResponse {
// The matching documents
repeated Document documents = 1;
}
// Create a search index by specifying which fields are to be queried
message CreateIndexRequest {
// the name of the index
string index = 1;
repeated Field fields = 2;
}
message Field {
// The name of the field. Use a `.` separator to define nested fields e.g. foo.bar
string name = 1;
// The type of the field - string, number
string type = 2;
}
message CreateIndexResponse {}
// Delete an index.
message DeleteIndexRequest {
// The name of the index to delete
string index = 1;
}
message DeleteIndexResponse {}