# ElasticSearch Index
## Description
The index operator index the given documents in ElasticSearch to get ready for retrieval. It accepts a single document in dictionary or a list of documents (dictionaries) as input.
To use this operator, you need to [set up ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html) in advance.
## Code Example
Insert an example document into ElasticSearch with address of localhost:9200 and index of 'test_index'.
```python
from towhee import pipe, ops, DataCollection
example_doc = {
'sentence': 'This is an example.',
}
es_insert = (
pipe.input('index_name', 'doc')
.map(('index_name', 'doc'), 'res', ops.elasticsearch.osschat_index(
host='localhost', port=9200
))
.map('doc', 'doc', lambda x: str(x))
.output('doc', 'res')
)
res = es_insert('test_index_5', example_doc)
DataCollection(res).show()
```
## Factory Constructor
Create the operator via the following factory method:
***elasticsearch.search(host='localhost', port=9200, user=None, password=None, ca_certs=None)***
**Parameters:**
***host***: *str*
The host to connect ElasticSearch client.
***port***: *int*
The port to connect ElasticSearch client.
***user***: *str*
The username to connect ElasticSearch client if needed, defaults to None.
***password***: *str*
The user password to connect ElasticSearch client if needed, defaults to None.
***ca_certs***: *str*
The path to CA certificates to connect ElasticSearch client if needed, defaults to None.
**Returns:**
Index response wrapped by `elastic_transport.ObjectApiResponse`.