Skip to content

manticoresoftware/manticoresearch-javascript

Repository files navigation

manticoresearch

Low-level client for Manticore Search.

Installation

npm install manticoresearch 

Requirements

Node v8.

Minimum Manticore Search version is 2.5.1 with HTTP protocol enabled.

Documentation

Full documentation is available in docs folder.

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

Getting Started

A simple search case:

const Manticoresearch = require('manticoresearch');

const client = new Manticoresearch.ApiClient();
client.basePath="http://127.0.0.1:9308"; 
const searchApi = new Manticoresearch.SearchApi(client);

async function() {
    const res =  await searchApi.search({"index":"forum","query":{"match_all":{},"bool":{"must":[{"equals":{"author_id":123}},{"in":{"forum_id":[1,3,7]}}]}},"sort":[{"post_date":"desc"}]});
    console.log(JSON.stringify(res));
}

Case with running a SELECT SphinxQL, set as query parameter:

const Manticoresearch = require('manticoresearch');

const client = new Manticoresearch.ApiClient();
client.basePath="http://127.0.0.1:9308";
const searchApi = new Manticoresearch.UtilsApi(client);

async function() {
    const res =  await searchApi.sql(`mode=raw&query=SELECT * FROM idx_users WHERE match('${q}') LIMIT ${offset},${limit} 
      OPTION field_weights=(name=50,alternative_name=30,description=10)`);
    console.log(JSON.stringify(res));
}

Documentation for API Endpoints

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

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

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization.