Socket
Socket
Sign inDemoInstall

@dedel.alex/adonis5-elasticsearch

Package Overview
Dependencies
224
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dedel.alex/adonis5-elasticsearch

Elasticsearch Provider for AdonisJS 5


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 28 Mar 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc