Basic Query in Amazon Elasticsearch Service
Amazon Elasticsearch Service is a managed service that makes it easy to deploy, operate, and scale Elasticsearch in the AWS Cloud. Elasticsearch is a popular open-source search and analytics engine for use cases such as log analytics, real-time application monitoring, and clickstream analytics.
You will click on your endpoint then you will be got this type of output. It means your connectivity has established.
Post Data(Create Data in index):-
Where:- test
is index and _doc
is a document.
$ curl -XPOST --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/Amazon Elasticsearch Service/_doc -d '{
"skills" : [
"a"
],
"name" : "Ankit Rajpootttt",
"email" : "rajputankit22@gmail.com",
"address" : {
"address" : "A/27 Bhopal",
"city" : "Bhopal",
"pin" : 487551,
"state" : "M.P."
},
"dob" : "2019-12-11T00:00:00.000Z",
"higerEducation" : "MCA"
}'
Search all document without Index
$ curl -XGET --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/_search
Search all data with Index
Where:- test
is index name.
$ curl -XGET --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/test/_search
Universal search:- In this search text will be matched in each field.
Where:- test
is index name and Ankit
is a searching text.
$ curl -XGET --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/test/_search\?q=Ankit
Search value in a single field
$ curl -XGET --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/test/_search\?q=name:Rajpootttt
Search through id with query
curl -XGET --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/test/_search\?q=_id:4gI4knQB7d5sAgV24YPy
Search through id without query
curl -XGET --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/test/_doc/4gI4knQB7d5sAgV24YPy
Delete a document from index through the id
curl -XDELETE --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/test/_doc/ogLWkXQB7d5sAgV2AIMf
Update object through id
curl -XPUT --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/test/_doc/4gI4knQB7d5sAgV24YPy -d '{
"skills" : [
"a"
],
"name" : "Ankit Singh",
"email" : "ankit@gmail.com",
"address" : {
"address" : "A/27 Bhopal",
"city" : "Bhopal",
"pin" : 487551,
"state" : "M.P."
},
"dob" : "2019-12-11T00:00:00.000Z",
"higerEducation" : "MCA"
}'
Update single field through id
$ curl -XPOST --header 'Content-Type: application/json' https://search-testarticle-2cwv6oh7wtz3hxowgxv3rprnsa.ap-south-1.es.amazonaws.com/test/_update/4gI4knQB7d5sAgV24YPy -d '{"doc":{ "name" : "Ankit Singh Raj"}}'
That’s it for this time! I hope you enjoyed this post. As always, I welcome questions, notes, comments and requests for posts on topics you’d like to read. See you next time! Happy Coding !!!!!