Skip to content

guimachiavelli/meilisearch-js

Repository files navigation

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

CircleCI Dependabot 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

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

// Get your applicationId and apiKey on meilisearch.com
const config = {
  host: 'xxx',
  apiKey: 'xxx',
}

const meili = new Meili(config)

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

🎭 Examples

Go checkout examples !

πŸ“œ API

Make a search

Example:

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

List existing indexes

This methods list all indexes of a database

Example:

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

Create new index

This methods create a new index

Example:

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

Get some documents

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(indexUid: string).updateInfo(updateId: number): Promise<object>

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

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

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

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

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

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

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

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

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

Index(indexUid: 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

About

JavaScript client for the Meilisearch API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 96.2%
  • JavaScript 3.4%
  • Other 0.4%