Skip to content

Files

Latest commit

d82b884 · Mar 24, 2025

History

History
executable file
·
196 lines (108 loc) · 8.8 KB

IndexApi.md

File metadata and controls

executable file
·
196 lines (108 loc) · 8.8 KB

\IndexApi

All URIs are relative to http://127.0.0.1:9308

Method HTTP request Description
bulk Post /bulk Bulk table operations
delete Post /delete Delete a document in a table
insert Post /insert Create a new document in a table
partial_replace Post /{table}/_update/{id} Partially replaces a document in a table
replace Post /replace Replace new document in a table
update Post /update Update a document in a table

bulk

crate::models::BulkResponse bulk(body) Bulk table operations

Sends multiple operatons like inserts, updates, replaces or deletes. For each operation it's object must have same format as in their dedicated method. The method expects a raw string as the batch in NDJSON. Each operation object needs to be serialized to JSON and separated by endline (\n). An example of raw input: {\"insert\": {\"table\": \"movies\", \"doc\": {\"plot\": \"A secret team goes to North Pole\", \"rating\": 9.5, \"language\": [2, 3], \"title\": \"This is an older movie\", \"lon\": 51.99, \"meta\": {\"keywords\":[\"travel\",\"ice\"],\"genre\":[\"adventure\"]}, \"year\": 1950, \"lat\": 60.4, \"advise\": \"PG-13\"}}} \\n {\"delete\": {\"table\": \"movies\",\"id\":700}} Responds with an object telling whenever any errors occured and an array with status for each operation: { 'items': [ { 'update':{'table':'products','id':1,'result':'updated'} }, { 'update':{'table':'products','id':2,'result':'updated'} } ], 'errors':false }

Parameters

Name Type Description Required Notes
body String [required]

Return type

crate::models::BulkResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/x-ndjson
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

delete

crate::models::DeleteResponse delete(delete_document_request) Delete a document in a table

Delete one or several documents. The method has 2 ways of deleting: either by id, in case only one document is deleted or by using a match query, in which case multiple documents can be delete . Example of input to delete by id: {'table':'movies','id':100} Example of input to delete using a query: { 'table':'movies', 'query': { 'bool': { 'must': [ {'query_string':'new movie'} ] } } } The match query has same syntax as in for searching. Responds with an object telling how many documents got deleted: {'table':'products','updated':1}

Parameters

Name Type Description Required Notes
delete_document_request DeleteDocumentRequest [required]

Return type

crate::models::DeleteResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

insert

crate::models::SuccessResponse insert(insert_document_request) Create a new document in a table

Insert a document. Expects an object like: { 'table':'movies', 'id':701, 'doc': { 'title':'This is an old movie', 'plot':'A secret team goes to North Pole', 'year':1950, 'rating':9.5, 'lat':60.4, 'lon':51.99, 'advise':'PG-13', 'meta':'{\"keywords\":{\"travel\",\"ice\"},\"genre\":{\"adventure\"}}', 'language':[2,3] } } The document id can also be missing, in which case an autogenerated one will be used: { 'table':'movies', 'doc': { 'title':'This is a new movie', 'plot':'A secret team goes to North Pole', 'year':2020, 'rating':9.5, 'lat':60.4, 'lon':51.99, 'advise':'PG-13', 'meta':'{\"keywords\":{\"travel\",\"ice\"},\"genre\":{\"adventure\"}}', 'language':[2,3] } } It responds with an object in format: {'table':'products','id':701,'created':true,'result':'created','status':201}

Parameters

Name Type Description Required Notes
insert_document_request InsertDocumentRequest [required]

Return type

crate::models::SuccessResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

partial_replace

crate::models::UpdateResponse partial_replace(table, id, replace_document_request) Partially replaces a document in a table

Partially replaces a document with given id in a table Responds with an object of the following format: {'table':'products','updated':1}

Parameters

Name Type Description Required Notes
table String Name of the percolate table [required]
id i64 Id of the document to replace [required]
replace_document_request ReplaceDocumentRequest [required]

Return type

crate::models::UpdateResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

replace

crate::models::SuccessResponse replace(insert_document_request) Replace new document in a table

Replace an existing document. Input has same format as insert operation. Responds with an object in format: {'table':'products','id':1,'created':false,'result':'updated','status':200}

Parameters

Name Type Description Required Notes
insert_document_request InsertDocumentRequest [required]

Return type

crate::models::SuccessResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

update

crate::models::UpdateResponse update(update_document_request) Update a document in a table

Update one or several documents. The update can be made by passing the id or by using a match query in case multiple documents can be updated. For example update a document using document id: {'table':'movies','doc':{'rating':9.49},'id':100} And update by using a match query: { 'table':'movies', 'doc':{'rating':9.49}, 'query': { 'bool': { 'must': [ {'query_string':'new movie'} ] } } } The match query has same syntax as for searching. Responds with an object that tells how many documents where updated in format: {'table':'products','updated':1}

Parameters

Name Type Description Required Notes
update_document_request UpdateDocumentRequest [required]

Return type

crate::models::UpdateResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]