All URIs are relative to http://127.0.0.1:9308
| Method | HTTP request | Description |
|---|---|---|
| bulk | POST /json/bulk | Bulk index operations |
| callDelete | POST /json/delete | Delete a document in an index |
| insert | POST /json/insert | Create a new document in an index |
| replace | POST /json/replace | Replace new document in an index |
| update | POST /json/update | Update a document in an index |
BulkResponse bulk(body)
Bulk index 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" : "products", "id" : 3, "doc" : {"title" : "Crossbody Bag with Tassel", "price" : 19.85}}}\n
{"insert": {"table" : "products", "id" : 4, "doc" : {"title" : "microfiber sheet set", "price" : 19.99}}}\n
{"insert": {"table" : "products", "id" : 5, "doc" : {"title" : "CPet Hair Remover Glove", "price" : 7.99}}}
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}
var Manticoresearch = require('manticoresearch');
var indexApi = new Manticoresearch.IndexApi();
async function(){
let docs = [
{"insert": {"table" : "products", "id" : 3, "doc" : {"title" : "Crossbody Bag with Tassel", "price" : 19.85}}},
{"insert": {"table" : "products", "id" : 4, "doc" : {"title" : "microfiber sheet set", "price" : 19.99}}},
{"insert": {"table" : "products", "id" : 5, "doc" : {"title" : "CPet Hair Remover Glove", "price" : 7.99}}}
];
res = await indexApi.bulk(docs.map(e=>JSON.stringify(e)).join('\n'));
console.log(JSON.stringify(res));
}| Name | Type | Description | Notes |
|---|---|---|---|
| body | String |
No authorization required
- Content-Type: application/x-ndjson
- Accept: application/json
DeleteResponse callDelete(deleteDocumentRequest)
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" : "products", "id" : 1}
Example of input to delete using a query:
{"table" : "products", "query": { "match": { "*": "superseeded" }}}
The match query has same syntax as in for searching. Responds with an object telling how many documents got deleted:
{'table':'products','updated':1}
var Manticoresearch = require('manticoresearch');
var indexApi = new Manticoresearch.IndexApi();
async function() {
res = await indexApi.callDelete({"table" : "products", "id" : 1});
console.log(JSON.stringify(res));
}| Name | Type | Description | Notes |
|---|---|---|---|
| deleteDocumentRequest | DeleteDocumentRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
SuccessResponse insert(insertDocumentRequest)
Create a new document in a table
Insert a document. Expects an object like:
{"table" : "products", "id" : 1, "doc" : {"title" : "Crossbody Bag with Tassel", "price" : 19.85}}
The document id can also be missing, in which case an autogenerated one will be used:
{"table" : "products", "id" : 0, "doc" : {"title" : "Yellow bag"}}
It responds with an object in format:
{'table':'products','_id':1,'created':true,'result':'created','status':201}
var Manticoresearch = require('manticoresearch');
var indexApi = new Manticoresearch.IndexApi();
async function(){
res = await indexApi.insert({"table" : "products", "id" : 1, "doc" : {"title" : "Crossbody Bag with Tassel", "price" : 19.85}});
}| Name | Type | Description | Notes |
|---|---|---|---|
| insertDocumentRequest | InsertDocumentRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
SuccessResponse replace(insertDocumentRequest)
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}
var Manticoresearch = require('manticoresearch');
var indexApi = new Manticoresearch.IndexApi();
async function(){
res = await indexApi.replace({"table" : "products", "id" : 1, "doc" : {"title" : "document one","price":10}});
} | Name | Type | Description | Notes |
|---|---|---|---|
| insertDocumentRequest | InsertDocumentRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
UpdateResponse update(updateDocumentRequest)
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" : "products", "id" : 1, "doc" : {"price":10}}
And update by using a match query:
{'table':'products','doc':"price":10},'query':{'bool':{'must':[{'query_string':'yellow bag'}]}}}
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}
var Manticoresearch = require('manticoresearch');
var indexApi = new Manticoresearch.IndexApi();
async function() {
res = await indexApi.update({"table" : "products", "id" : 1, "doc" : {"price":10}});
}| Name | Type | Description | Notes |
|---|---|---|---|
| updateDocumentRequest | UpdateDocumentRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json