description |
---|
Frequently used code for Elasticsearch |
Using httpie library for the requests
Create an Index
http PUT HOST:PORT/{index-name}/_alias/{alias-name}
Check if index exists
http GET HOST:PORT/{index-name}
# The resultant status code would tell if found(200, or 404)
Get index with a given alias
http GET HOST:PORT/_alias/{alias-name}
Delete an Index
http DELETE HOST:PORT/{index-name}
Example of search
# using httpie
http elasticsearch2:9200/ascendsport-en/_search?_source="question,_id,answer" Content-Type:application/json query:='{"match": {"question": "what is telegram"}}'