Coder Social home page Coder Social logo

elasticsearch-service-class's Introduction

Elastic Search Service Class

This Elastic Search service class, authored by Abeer Elghool, provides a streamlined interface for working with Elastic Search.

Prerequisites

Before using this class, you will need to ensure that Elastic Search is installed and running on your machine.

Additionally, you will need to install the elasticsearch/elasticsearch package using Composer.

Configuration

To use this class, you will need to set the following environment variables:

  • ELASTIC_HOST: The URL of your Elastic Search instance. If this variable is not set, the default URL of http://localhost:9200 will be used.
  • ELASTIC_PASSWORD: The password for your Elastic Search instance.

Usage

To use this class, simply create a new instance of the ElasticsearchService class:

use App\Services\ElasticsearchService;

$elasticsearchService = new ElasticsearchService();

Once you have an instance of the ElasticsearchService class, you can call its methods to perform various operations on your Elastic Search instance, such as searching for documents, storing new documents, and deleting documents or indexes.

Methods

The following methods are available in the ElasticsearchService class:

public function search(string $search, array $indexes): array;
public function checkOrCreateIndex(string $index): bool;
public function storeDocument(string $index, array $data): bool;
public function deleteDocument(string $index, string $id): void;
public function deleteIndex(string $index): void;

search(string $search, array $indexes): array

Search for documents in the specified indexes that match the given query.

  • $search: The search query.
  • $indexes: The indexes to search in.
  • Returns: The search results.

checkOrCreateIndex(string $index): bool

Check if an index exists, and if not, create it.

  • $index: The name of the index.

elasticsearch-service-class's People

Contributors

abeer-elghool avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.