Skip to content

manticoresoftware/manticoresearch-javascript

Repository files navigation

Manticore Javascript client

Сlient for Manticore Search.

Requirements

Minimum Manticore Search version is 2.5.1 with HTTP protocol enabled.

Installation

npm install manticoresearch 

Getting Started

Please follow the installation instruction and execute the following Javascript code:

var Manticoresearch = require('manticoresearch');
var client = new Manticoresearch.ApiClient();
client.basePath="http://localhost:9308";
/*
If a custom http agent is needed, e.g., to enable keep-alive connections, the 'requestAgent' option can be set to override 'superagent' agent instance used by default:
client.requestAgent = new http.Agent({
  keepAlive: true,
  maxSockets: 1,
  keepAliveMsecs: 1000
});
*/

var api = new Manticoresearch.IndexApi(client)
var body = ["'{\"insert\": {\"index\": \"test\", \"id\": 1, \"doc\": {\"title\": \"Title 1\"}}},\\n{\"insert\": {\"index\": \"test\", \"id\": 2, \"doc\": {\"title\": \"Title 2\"}}}'"]; // {String} 
api.bulk(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

var searchApi = new Manticoresearch.SearchApi(client);

// Create SearchRequest
var searchRequest = new Manticoresearch.SearchRequest();
searchRequest.index = "test";
searchRequest.fulltext_filter = new Manticoresearch.QueryFilter('Star Trek 2');

// Perform a search
async function(){
    var res = await searchApi.search(searchRequest);
    console.log(JSON.stringify(res, null, 4));
}

Documentation

Full documentation on the API Endpoints and Models used is available in docs folder as listed below.

Manticore Search server documentation: https://manual.manticoresearch.com.

Documentation for API Endpoints

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

Class Method HTTP request Description
Manticoresearch.IndexApi bulk POST /bulk Bulk index operations
Manticoresearch.IndexApi callDelete POST /delete Delete a document in an index
Manticoresearch.IndexApi insert POST /insert Create a new document in an index
Manticoresearch.IndexApi replace POST /replace Replace new document in an index
Manticoresearch.IndexApi update POST /update Update a document in an index
Manticoresearch.SearchApi percolate POST /pq/{index}/search Perform reverse search on a percolate index
Manticoresearch.SearchApi search POST /search Performs a search on an index
Manticoresearch.UtilsApi sql POST /sql Perform SQL requests

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization.