Home Reference Source

Sajari Javascript SDK

npm docs license

The Sajari Javascript SDK provides web integration for browsers.

Sajari Search is a hosted search and recommendation service supporting instant search, faceted search, recommendations and custom matching algorithms

This module is for querying the search service. If you want automated indexing, profiling and convenience functions for rendering HTML, please check out sajari-website instead.

Table of Contents

Setup

sajari is 11KB gzipped.

NPM, Browserify, webpack

npm install sajari --save

Getting Started

import { Client, Query, Tracking, body } from 'sajari'

const client = new Client('project', 'collection')
const query = new Query()

query.body([
  body("foo bar")
])

client.search(query, new Tracking(), (err, res) => {
  console.log(err, res)
})

The Client object handles the requesting and callbacks. If you need to override the default address, you can supply an extra parameter to Client:

new Client('project', 'collection', 'http://localhost:8000')

The Query object handles the query state. Use the methods on it to define your queries.

Documentation

Documentation can be found at https://doc.esdoc.org/github.com/sajari/sajari-sdk-js/.

License

We use the MIT license

Browser Support

This library uses the Fetch API. Fetch is available on all evergreen browsers (Chrome, Firefox, Edge), see here for a more complete overview. We recommend using isomorphic-fetch to increase compatibility across other browsers and Node.js.