Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@meilisearch/meili-api
Advanced tools
The Javascript client for MeiliSearch API.
MeiliSearch provides an ultra relevant and instant full-text search. Our solution is open-source and you can check out our repository here.
Here is the MeiliSearch documentation 📖
npm install @meilisearch/meili-api
yarn add @meilisearch/meili-api
There are many easy ways to download and run a MeiliSearch instance.
For example, if you use Docker:
$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest --api-key=apiKey
NB: you can also download MeiliSearch from Homebrew or APT.
Here is a quickstart for a search request
const Meili = require('@meilisearch/meili-api')
// Credentials of your MeiliSearch Instance
const config = {
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
}
const meili = new Meili(config)
meili
.Index('movies')
.search({ q: 'batman' })
.then((response) => {
console.log(response.hits)
})
Go checkout examples!
Example:
meili
.Index('movies')
.search({
q: 'batman',
})
.then((response) => {
console.log(response.hits)
})
Response:
{
"hits": [
{
"id": "2661",
"title": "Batman",
"poster": "https://image.tmdb.org/t/p/w1280/udDVJXtAFsQ8DimrXkVFqy4DGEQ.jpg",
"overview": "The Dynamic Duo faces four super-villains who plan to hold the world for ransom with the help of a secret invention that instantly dehydrates people.",
"release_date": -108086400
},
{
"id": "268",
"title": "Batman",
"poster": "https://image.tmdb.org/t/p/w1280/kBf3g9crrADGMc2AMAMlLBgSm2h.jpg",
"overview": "The Dark Knight of Gotham City begins his war on crime with his first major enemy being the clownishly homicidal Joker, who has seized control of Gotham's underworld.",
"release_date": 614566800
},
{
"id": "29751",
"title": "Batman Unmasked: The Psychology of the Dark Knight",
"poster": "https:/0/image.tmdb.org/t/p/w1280/jjHu128XLARc2k4cJrblAvZe0HE.jpg",
"overview": "Delve into the world of Batman and the vigilante justice that he brought to the city of Gotham. Batman is a man who, after experiencing great tragedy, devotes his life to an ideal--but what happens when one man takes on the evil underworld alone? Examine why Batman is who he is--and explore how a boy scarred by tragedy becomes a symbol of hope to everyone else.",
"release_date": 1216083600
}
],
"offset": 0,
"limit": 3,
"processingTimeMs": 4,
"query": "batman"
}
This methods list all indexes of a database
Example:
meili.listIndexes().then((indexes) => {
console.log(indexes)
})
Response:
[
{
"name": "Movies",
"uid": "movies",
"createdAt": "2019-11-25T14:06:54.340482Z",
"updatedAt": "2019-11-25T14:07:00.736937Z"
}
]
This methods create a new index
Example:
meili
.createIndex({
name: 'Movie',
uid: 'movies',
})
.then((indexes) => {
console.log(indexes)
})
Response:
{
"name": "Movies",
"uid": "movies",
"createdAt": "2019-11-25T14:38:49.846352Z",
"updatedAt": "2019-11-25T14:38:49.846353Z"
}
Will push to the indexing queue documents on body
Example:
meili
.Index('movies')
.addDocuments([
{
id: 1,
title: 'My awesome movie',
},
])
.then((indexes) => {
console.log(indexes)
})
Response:
{
"updateId": 1
}
The method add_documents
is asynchronous.
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('movies')
.browse({
limit: 3,
})
.then((response) => {
console.log(response)
})
Reponse:
[
{
"id": "279664",
"title": "Green Chair 2013 - Love Conceptually",
"poster": "https://image.tmdb.org/t/p/w1280/9H8vACDBSBs8NXO6NfLH3i9ZsYq.jpg",
"overview": "Moon-hee is an attractive woman who runs an art academy after returning from the States. She lives apart from her husband who won't divorce her and enjoys a free relationship with In-gyu, her lover of long time and Professor Yoon whom she's been privately involved with for a long time. On the other hand, her young student Joo Won only draws her face during class. He fell in love with her when he saw Moon-hee as a bride at the wedding his grandma took him too. He started art because of her and started attending the academy. He thinks it's destiny. Moon-hee is attracted to Joo Won's pure heart until they share love in in a studio where it's just them....",
"release_date": 1383177600
},
{
"id": "13342",
"title": "Fast Times at Ridgemont High",
"poster": "https://image.tmdb.org/t/p/w1280/9y5rSeO0xH3m5oRJmhBusDkiS0j.jpg",
"overview": "Follows a group of high school students growing up in southern California, based on the real-life adventures chronicled by Cameron Crowe. Stacy Hamilton and Mark Ratner are looking for a love interest, and are helped along by their older classmates, Linda Barrett and Mike Damone, respectively. The center of the film is held by Jeff Spicoli, a perpetually stoned surfer dude who faces off with the resolute Mr. Hand, who is convinced that everyone is on dope.",
"release_date": 398048400
},
{
"id": "25087",
"title": "Bloodsport II",
"poster": "https://image.tmdb.org/t/p/w1280/xVfSGAbOK4FucTwkYrXJjeBFqv4.jpg",
"overview": "After thief Alex Cardo gets caught while stealing an ancient katana in East Asia, he soon finds himself imprisoned and beaten up by the crowd there. One of the guards, Demon, feels upset by Alex appearance and tortures him as often as he gets the opportunity. Alex finds a friend and mentor in the jailhouse, Master Sun, who teaches him a superior fighting style called Iron Hand. When a 'best of the best kumite' is to take place, Demon gets an invitation. Now Master Sun and Alex need to find a way to let Alex take part in the kumite too.",
"release_date": 825638400
}
]
meili.Index('xxx').search(options: Types.SearchParams): Promise<Types.SearchResponse>
meili.listIndexes(): Promise<object[]>
meili.createIndex(data: Types.CreateIndexRequest): Promise<Types.CreateIndexResponse>
meili.Index('xxx').getIndex(): Promise<Types.index>
meili.Index('xxx').updateIndex(data: Types.UpdateIndexRequest): Promise<Types.index>
meili.Index('xxx').deleteIndex(): Promise<void>
meili.Index('xxx').getStats(): Promise<object>
meili.Index('xxx').getUpdate(updateId: number): Promise<object>
meili.Index('xxx').getAllUpdates(): Promise<object[]>
meili.Index('xxx').addDocuments(documents: object[]): Promise<Types.AsyncUpdateId>
meili.Index('xxx').getDocuments(params: Types.getDocumentsParams): Promise<object[]>
meili.Index('xxx').getDocument(documentId: string): Promise<object>
meili.Index('xxx').deleteDocument(documentId: string): Promise<Types.AsyncUpdateId>
meili.Index('xxx').deleteDocuments(documentsIds: string[]): Promise<Types.AsyncUpdateId>
meili.Index('xxx').getSettings(): Promise<object>
meili.Index('xxx').updateSettings(settings: object): Promise<void>
meili.Index('xxx').listSynonyms(): Promise<object[]>
meili.Index('xxx').createSynonym(input: string, synonyms: string[]): Promise<object>
Waiting on MeiliSearch v0.9.0
meili.isHealthy(): Promise<void>
meili.setHealthy(): Promise<void>
meili.setUnhealthy(): Promise<void>
meili.changeHealthTo(health: boolean): Promise<void>
meili.databaseStats(): Promise<object>
meili.version(): Promise<object>
meili.systemInformation(): Promise<object>
meili.systemInformationPretty(): Promise<object>
FAQs
The MeiliSearch JS client for Node.js and the browser.
We found that @meilisearch/meili-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.