/js-meili-api

Primary LanguageTypeScriptMIT LicenseMIT

meili-api

This is the javascript wrapper to the meili API Meili provides a instant search engine as a service, you can register on meilisearch.com to get your credentials. You can also try it on your own by installing MeiliDB on your computer.

πŸ‘·πŸΎβ€β™‚οΈThis is a work in progress, if you need more information on the meili API, you should visit the API documentation

Build Status NPM version Downloads Standard Version styled with prettier Conventional Commits


✨ Features

  • Search documents in meili API
  • Index documents in meili API

πŸ”§ Installation

npm install @meilisearch/meili-api
yarn add @meilisearch/meili-api

🎬 Getting started

Here is a quickstart for a search request

var Meili = require('@meilisearch/meili-api')

// Get your applicationId and apiKey on meilisearch.com
var config = {
  applicationId: 'applicationUid',
  apiKey: 'apiKey',
}

var meili = new Meili(config)

meili
  .Index('indexUid')
  .search(
    { q: 'batman' }
  )
  .then((response) => {
    console.log(response.hits)
  })

🎭 Examples

Go checkout examples !

πŸ“œ API

Index(indexId: string).search(queryParams: object): Promise<object>

Example:

meili
  .Index('xxx')
  .search({
    q: 'batman',
  })
  .then((response) => {
    console.log(response.hits)
  })

listIndexes(): Promise<string[]>

This methods list all indexes of a database

Example:

meili.listIndexes().then((indexes) => {
  console.log(indexes) // ["movies"]
})

createIndex(indexId: string, schema: Schema): Promise<void>

This methods create a new index

Example:

meili.createIndex('movies', {
  id: ['identifier', 'indexed', 'displayed'],
  title: ['displayed', 'indexed'],
  poster: ['indexed', 'displayed'],
})

Index(indexId: string).browse(queryParams: object): Promise<object[]>

Browse is a method to get defaults documents without search. This method is usually used to display results when you have no input in the search bar.

Example:

meili
  .Index('xxx')
  .browse()
  .then((response) => {
    console.log(response)
  })

Index(indexId: string).updateInfo(updateId: number): Promise<object>

Index(indexId: string).getSchema(): Promise<object>

Index(indexId: string).Documents().addDocuments(documents: object[]): Promise<object>

Index(indexId: string).Documents().getDocument(documentId: string): Promise<object>

Index(indexId: string).Documents().deleteDocument(documentId: string): Promise<object>

Index(indexId: string).Documents().deleteDocuments(documents: object[]): Promise<object>

Index(indexId: string).Documents().batchWrite(documentsToInsert: object[], documentsToDelete: object[]): Promise<object>

Index(indexId: string).Settings().get(): Promise<object>

Index(indexId: string).Settings().set(settings: object): Promise<void>

Index(indexId: string).Synonyms().list(): Promise<object[]>

Index(indexId: string).Synonyms().create(input: string, synonyms: string[]): Promise<object>

πŸŽ“ Guides

How to do Foo Today we're gonna build Foo....

πŸ•΅οΈ Troubleshooting

πŸ₯‚ License

MIT as always