class_docstr: Sparse index using Elasticsearch. It is used to index text and run queries based on BM25 similarity.
  An Elasticsearch server needs to be accessible, and a python client is declared with
  ```
  es_client = Elasticsearch([{'host': 'localhost', 'port': '9200'}])
  ```
  for example.
class_docstr_tok: ["Sparse","index","using","Elasticsearch",".","It","is","used","to","index","text","and","run","queries","based","on","BM25","similarity",".","An","Elasticsearch","server","needs","to","be","accessible",",","and","a","python","client","is","declared","with","``","`","es_client","=","Elasticsearch","(","[","{","'host","'",":","'localhost","'",",","'port","'",":","'9200","'","}","]",")","``","`","for","example","."]
code: def __init__(
      self,
      host: Optional[str] = None,
      port: Optional[int] = None,
      es_client: Optional["Elasticsearch"] = None,
      es_index_name: Optional[str] = None,
      es_index_config: Optional[dict] = None,
  ):
      if not _has_elasticsearch:
          raise ImportError(
              "You must install ElasticSearch to use ElasticSearchIndex. To do so you can run `pip install elasticsearch==7.7.1 for example`"
          )
      if es_client is not None and (
          host is not None or port is not None
      ):
          raise ValueError(
              "Please specify either `es_client` or `(host, port)`, but not both."
          )
      host = host or "localhost"
      port = port or 9200
  
      import elasticsearch.helpers  # noqa: F401 - need this to properly load all the es features
      from elasticsearch import Elasticsearch  # noqa: F811
  
      self.es_client = (
          es_client
          if es_client is not None
          else Elasticsearch([{"host": host, "port": str(port)}])
      )
      self.es_index_name = (
          es_index_name
          if es_index_name is not None
          else "huggingface_datasets_"
          + os.path.basename(tempfile.NamedTemporaryFile().name)
      )
      self.es_index_config = (
          es_index_config
          if es_index_config is not None
          else {
              "settings": {
                  "number_of_shards": 1,
                  "analysis": {
                      "analyzer": {
                          "stop_standard": {
                              "type": "standard",
                              " stopwords": "_english_",
                          }
                      }
                  },
              },
              "mappings": {
                  "properties": {
                      "text": {
                          "type": "text",
                          "analyzer": "standard",
                          "similarity": "BM25",
                      }
                  }
              },
          }
      )
  
imports: import importlib.util
  import os
  import tempfile
  from pathlib import PurePath
  from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Union
  import fsspec
  import numpy
  from .utils import logging
  from .utils import tqdm
label_desc: Use image node_id 1 to create a new ElasticSearchIndex object from inherited base classes: BaseIndex with example: obj = ElasticSearchIndex(host, port, es_client, es_index_name, es_index_config)