@dedel.alex/adonis5-elasticsearch
TypeScript icon, indicating that this package has built-in type declarations

8.17.1 • Public • Published

Install Elasticsearch Provider in Adonis

Install dependency

npm i @dedel.alex/adonis5-elasticsearch

Run command

node ace configure @dedel.alex/adonis5-elasticsearch

Configure Elasticsearch

# Elasticsearch HOST
ELASTICSEARCH_URI=https://127.0.0.1:9200

# Elasticsearch user
ELASTICSEARCH_USER="elastic"

# Elasticsearch password
ELASTICSEARCH_PASSWORD=""

# Elasticsearch options
ELASTICSEARCH_OPTIONS=""

Usage

Here is an example of how to use the Elasticsearch Provider:

import client from "@ioc:Adonis/Addons/Elasticsearch";

// Get index - where the documents are stored.
const index = await client.index({
  index: "game-of-thrones",
  document: {
    character: "Ned Stark",
    quote: "Winter is coming.",
  },
});

// here we are forcing an index refresh, otherwise we will not
// get any result in the consequent search
await client.indices.refresh({ index: "game-of-thrones" });

// Let's search!
const result = await client.search({
  index: "game-of-thrones",
  query: {
    match: { quote: "winter" },
  },
});

console.log(result.hits.hits);

For more information about Elasticsearch, check the offical website

Github project

https://github.com/aDedel/adonis5-elasticsearch

Package Sidebar

Install

npm i @dedel.alex/adonis5-elasticsearch

Weekly Downloads

6

Version

8.17.1

License

MIT

Unpacked Size

7.4 kB

Total Files

10

Last publish

Collaborators

  • dedel.alex