index-client
copied
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions
Updated 3 years ago
elasticsearch
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. For each document, the index automatically generates a unique id. To use this operator, you need to set up ElasticSearch in advance.
Code Example
Insert an example document into ElasticSearch with address of localhost:9200 and index of 'test_index'.
from datetime import datetime
from towhee.dc2 import pipe, ops, DataCollection
example_doc = {
'title': 'Test Title',
'author': 'Towhee',
'content': 'This is an example.',
'timestamp': datetime.now()
}
es_insert = (
pipe.input('doc')
.map('doc', 'res', ops.elasticsearch.index_client(
host='localhost', port=9200, index_name='test_index'
))
.output('doc', 'res')
)
res = es_insert(example_doc) # OR: es_insert([example_doc])
DataCollection(res).show() # Optional: display output data
|
| 2 Commits | ||
|---|---|---|---|
|
|
1.1 KiB
|
3 years ago | |
|
|
1.1 KiB
|
3 years ago | |
|
|
101 B
|
3 years ago | |
|
|
1.8 KiB
|
3 years ago | |