All Projects → typesense → Typesense Instantsearch Adapter

typesense / Typesense Instantsearch Adapter

Licence: mit
A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Typesense Instantsearch Adapter

Search Ui
Search UI. Libraries for the fast development of modern, engaging search experiences.
Stars: ✭ 1,294 (+2210.71%)
Mutual labels:  search, search-interface
Instantsearch Ios Examples
Example apps built with InstantSearch iOS
Stars: ✭ 55 (-1.79%)
Mutual labels:  search, search-interface
Awesome Solr
A curated list of Awesome Apache Solr links and resources.
Stars: ✭ 69 (+23.21%)
Mutual labels:  search, search-interface
Search Query Parser
A simple parser for advanced search query syntax
Stars: ✭ 180 (+221.43%)
Mutual labels:  search, search-interface
Instantsearch Ios
⚡️ A library of widgets and helpers to build instant-search applications on iOS.
Stars: ✭ 498 (+789.29%)
Mutual labels:  search, search-interface
Ransack
Object-based searching.
Stars: ✭ 5,020 (+8864.29%)
Mutual labels:  search, search-interface
Instantsearch Android
A library of widgets and helpers to build instant-search applications on Android.
Stars: ✭ 129 (+130.36%)
Mutual labels:  search, search-interface
Calaca
Search UI for Elasticsearch
Stars: ✭ 318 (+467.86%)
Mutual labels:  search, search-interface
Open Semantic Search
Open Source research tool to search, browse, analyze and explore large document collections by Semantic Search Engine and Open Source Text Mining & Text Analytics platform (Integrates ETL for document processing, OCR for images & PDF, named entity recognition for persons, organizations & locations, metadata management by thesaurus & ontologies, search user interface & search apps for fulltext search, faceted search & knowledge graph)
Stars: ✭ 386 (+589.29%)
Mutual labels:  search, search-interface
Search Dialog
An easy to use, yet very customizable search dialog
Stars: ✭ 503 (+798.21%)
Mutual labels:  search, search-interface
Open Semantic Search Apps
Python/Django based webapps and web user interfaces for search, structure (meta data management like thesaurus, ontologies, annotations and named entities) and data import (ETL like text extraction, OCR and crawling filesystems or websites)
Stars: ✭ 55 (-1.79%)
Mutual labels:  search, search-interface
Docker registry cli
Docker Registry CLI - Provides search functionality for Docker Registry (UI and CLI)
Stars: ✭ 48 (-14.29%)
Mutual labels:  search
Torrenter
Simple nodejs package to download torrents using torrent-indexer and webtorrent, especially movie and series.
Stars: ✭ 42 (-25%)
Mutual labels:  search
Github Awesome Autocomplete
Add instant search capabilities to GitHub's search bar
Stars: ✭ 1,015 (+1712.5%)
Mutual labels:  search
Hatebupwa
Hatena Bookmark search app.
Stars: ✭ 42 (-25%)
Mutual labels:  search
React Emoji Search
🦄 A simple emoji search tool made with ReactJS.
Stars: ✭ 53 (-5.36%)
Mutual labels:  search
Duckduckgo Images Api
DuckDuckGo Image Search Resuts - Programatically download Image Search Results
Stars: ✭ 48 (-14.29%)
Mutual labels:  search
Hangfire.tags
Add tags to Hangfire backgroundjobs
Stars: ✭ 42 (-25%)
Mutual labels:  search
Lara Eye
Filter your Query\Builder using a structured query language
Stars: ✭ 39 (-30.36%)
Mutual labels:  search
Brim
Desktop application to efficiently search large packet captures and Zeek logs.
Stars: ✭ 976 (+1642.86%)
Mutual labels:  search

Typesense Instantsearch Adapter

An adapter to use the awesome Instantsearch.js library with a Typesense Search Server, to build rich search interfaces.

NPM version CircleCI

Here is an example of UI you can build with this adapater: songs-search.typesense.org

Quick Links

Background

The good folks over at Algolia have built and open-sourced Instantsearch.js which is a collection of out-of-the-box components that you can use to build interactive search experiences swiftly.

With the adapter in this repository, you'll be able to use Instantsearch (and its React, Vue and Angular cousins) with data indexed in a Typesense search server.

If you haven't used Instantsearch before, we recommend going through their Getting Started guide here. Once you go through the guide, follow the instructions below to plug the Typesense adapter into Instantsearch.

Quick Start

Here's a guide on building a quick search interface with Typesense and InstantSearch.js: https://typesense.org/docs/0.18.0/guide/#search-ui

Here's a demo app that showcases the adapter in action: https://github.com/typesense/typesense-instantsearch-demo

Installation

$ npm install --save typesense-instantsearch-adapter

or

$ yarn add typesense-instantsearch-adapter

Since this is an adapter, it will not install the Instantsearch library automatically for you. You need to install one of the following in your application directly:

You'll find information on how to get started with each of the above libraries in their respective repos.

We'd also recommend checking out create-instantsearch-app to create your Search UI from a starter template.

Usage

With instantsearch.js

import instantsearch from "instantsearch.js";
import { searchBox, hits } from "instantsearch.js/es/widgets";
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: "abcd", // Be sure to use the search-only-api-key
    nodes: [
      {
        host: "localhost",
        port: "8108",
        protocol: "http"
      }
    ]
  },
  // The following parameters are directly passed to Typesense's search API endpoint.
  //  So you can pass any parameters supported by the search endpoint below. 
  //  queryBy is required. 
  additionalSearchParameters: {
    queryBy: "name,description,categories"
  }
});
const searchClient = typesenseInstantsearchAdapter.searchClient;


const search = instantsearch({
  searchClient,
  indexName: "products"
});
search.addWidgets([
  searchBox({
    container: "#searchbox"
  }),
  hits({
    container: "#hits",
    templates: {
      item: `
        <div class="hit-name">
          {{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}}
        </div>
      `
    }
  })
]);

search.start();

You can add any of the Instantsearch widgets here that are supported by the adapter.

You'll also find a working example in test/support/testground. To run it, run npm run testground from the project root folder.

With react-instantsearch

import React from 'react';
import ReactDOM from 'react-dom';
import { SearchBox } from 'react-instantsearch-dom';
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: "abcd", // Be sure to use the search-only-api-key
    nodes: [
      {
        host: "localhost",
        port: "8108",
        protocol: "http"
      }
    ]
  },
  // The following parameters are directly passed to Typesense's search API endpoint.
  //  So you can pass any parameters supported by the search endpoint below. 
  //  queryBy is required. 
  additionalSearchParameters: {
    queryBy: "name,description,categories"
  }
});
const searchClient = typesenseInstantsearchAdapter.searchClient;

const App = () => (
  <InstantSearch
    indexName="products"
    searchClient={searchClient}
  >
    <SearchBox />
    <Hits />
  </InstantSearch>
);

You can then add any of the Instantsearch-React widgets here that are supported by the adapter.

With vue-instantsearch

App.vue:

<template>
  <ais-instant-search :search-client="searchClient" index-name="products">
    <ais-search-box />
    <ais-hits>
      <div slot="item" slot-scope="{ item }">
        <h2>{{ item.name }}</h2>
      </div>
    </ais-hits>
  </ais-instant-search>
</template>

<script>
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: "abcd", // Be sure to use the search-only-api-key
    nodes: [
      {
        host: "localhost",
        port: "8108",
        protocol: "http"
      }
    ]
  },
  // The following parameters are directly passed to Typesense's search API endpoint.
  //  So you can pass any parameters supported by the search endpoint below. 
  //  queryBy is required. 
  additionalSearchParameters: {
    queryBy: "name,description,categories"
  }
});
const searchClient = typesenseInstantsearchAdapter.searchClient;

export default {
  data() {
    return {
      searchClient,
    };
  },
};
</script>

You can then add any of the Instantsearch widgets here that are supported by the adapter.

With angular-instantsearch

// app.component.ts
import { Component } from '@angular/core';
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: "abcd", // Be sure to use the search-only-api-key
    nodes: [
      {
        host: "localhost",
        port: "8108",
        protocol: "http"
      }
    ]
  },
  // The following parameters are directly passed to Typesense's search API endpoint.
  //  So you can pass any parameters supported by the search endpoint below. 
  //  queryBy is required. 
  additionalSearchParameters: {
    queryBy: "name,description,categories"
  }
});
const searchClient = typesenseInstantsearchAdapter.searchClient;

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  config = {
    indexName: 'products',
    searchClient
  };
}

You can then add any of the Instantsearch widgets here that are supported by the adapter.

Widget Specific Instructions

hierarchicalMenu

For this widget, you want to create independent fields in the collection's schema with this specific naming convention:

  • field.lvl0
  • field.lvl1
  • field.lvl2

for a nested hierarchy of field.lvl0 > field.lvl1 > field.lvl2

Each of these fields can also hold an array of values. This is useful for handling multiple hierarchies.

sortBy

When instantiating this widget, you want to set the value of the index name to this particular format:

search.addWidgets([
  sortBy({
      container: "#sort-by",
      items: [
        { label: "Default", value: "products" },
        { label: "Price (asc)", value: "products/sort/price:asc" },
        { label: "Price (desc)", value: "products/sort/price:desc" }
      ]
    })
])

The generalized pattern for the value attribute is: <index_name>[/sort/<sort_by>]. The adapter will use the value in <sort_by> as the value for the sort_by search parameter.

Implementation Notes

  • If you need to specify a filter_by search parameter for Typesense, you want to use the appropriate configure InstantSearch widget. Setting filter_by inside the additionalQueryParameters config does not work, because InstantSearch internally overrides the filter_by field. So you want to use InstantSearch to configure it. Read more here.

Compatibility

Typesense Server typesense-instantsearch-adapter instantsearch.js react-instantsearch vue-instantsearch angular-instantsearch
>= v0.19 >= v1.0.0 >= 4.2.0 >= 6.0.0 >= 2.2.1 >= 3.0.0
>= v0.15 >= v0.3.0 >= 4.2.0 >= 6.0.0 >= 2.2.1 >= 3.0.0
>= v0.14 >= v0.2.0 >= 4.2.0 >= 6.0.0 >= 2.2.1 >= 3.0.0
>= v0.13 >= v0.1.0 >= 4.2.0 >= 6.0.0 >= 2.2.1 >= 3.0.0
>= v0.12 >= v0.0.4 >= 4.2.0 >= 6.0.0 >= 2.2.1 >= 3.0.0

If a particular version of the above libraries don't work with the adapter, please open a Github issue with details.

Widget Compatibility

This adapter works with all widgets in this list, except for the following:

  • geoSearch
  • queryRuleCustomData
  • queryRuleContext

Development

$ npm install
$ npm run typesenseServer
$ FORCE_REINDEX=true npm run indexTestData

$ npm link typesense-instantsearch-adapter
$ npm run testground

$ npm test

To release a new version, we use the np package:

$ npm install --global np
$ np 

# Follow instructions that np shows you

Help

If you have any questions or run into any problems, please create a Github issue and we'll try our best to help.

© 2020 Typesense, Inc.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].