Manticoresearch.Api.Index (manticoresearch v1.0.1)

API calls for all endpoints tagged Index.

Link to this section Summary

Functions

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": {"index": "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": {"index": "movies","id":700}} Responds with an object telling whenever any errors occured and an array with status for each operation: {'items':[{'update':{'_index':'products','_id':1,'result':'updated'}},{'update':{'_index':'products','_id':2,'result':'updated'}}],'errors':false}

Delete a document in an index 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: {'index':'movies','id':100} Example of input to delete using a query: {'index':'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: {'_index':'products','updated':1}

Create a new document in an index Insert a document. Expects an object like: {'index':'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: {'index':'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: {'_index':'products','_id':701,'created':true,'result':'created','status':201}

Replace new document in an index Replace an existing document. Input has same format as insert operation. <br/> Responds with an object in format: <br/> {'_index':'products','_id':1,'created':false,'result':'updated','status':200}

Update a document in an index 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: {'index':'movies','doc':{'rating':9.49},'id':100} And update by using a match query: {'index':'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: {'_index':'products','updated':1}

Link to this section Functions

Link to this function

bulk(connection, body, opts \\ [])

Specs

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": {"index": "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": {"index": "movies","id":700}} Responds with an object telling whenever any errors occured and an array with status for each operation: {'items':[{'update':{'_index':'products','_id':1,'result':'updated'}},{'update':{'_index':'products','_id':2,'result':'updated'}}],'errors':false}

Parameters

  • connection (Manticoresearch.Connection): Connection to server
  • body (String.t):
  • opts (KeywordList): [optional] Optional parameters

    Returns

} on success {:error, info} on failure

Link to this function

delete(connection, delete_document_request, opts \\ [])

Specs

Delete a document in an index 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: {'index':'movies','id':100} Example of input to delete using a query: {'index':'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: {'_index':'products','updated':1}

Parameters

  • connection (Manticoresearch.Connection): Connection to server
  • delete_document_request (DeleteDocumentRequest):
  • opts (KeywordList): [optional] Optional parameters

    Returns

} on success {:error, info} on failure

Link to this function

insert(connection, insert_document_request, opts \\ [])

Specs

Create a new document in an index Insert a document. Expects an object like: {'index':'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: {'index':'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: {'_index':'products','_id':701,'created':true,'result':'created','status':201}

Parameters

  • connection (Manticoresearch.Connection): Connection to server
  • insert_document_request (InsertDocumentRequest):
  • opts (KeywordList): [optional] Optional parameters

    Returns

} on success {:error, info} on failure

Link to this function

replace(connection, insert_document_request, opts \\ [])

Specs

Replace new document in an index Replace an existing document. Input has same format as insert operation. <br/> Responds with an object in format: <br/> {'_index':'products','_id':1,'created':false,'result':'updated','status':200}

Parameters

  • connection (Manticoresearch.Connection): Connection to server
  • insert_document_request (InsertDocumentRequest):
  • opts (KeywordList): [optional] Optional parameters

    Returns

} on success {:error, info} on failure

Link to this function

update(connection, update_document_request, opts \\ [])

Specs

Update a document in an index 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: {'index':'movies','doc':{'rating':9.49},'id':100} And update by using a match query: {'index':'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: {'_index':'products','updated':1}

Parameters

  • connection (Manticoresearch.Connection): Connection to server
  • update_document_request (UpdateDocumentRequest):
  • opts (KeywordList): [optional] Optional parameters

    Returns

} on success {:error, info} on failure