URL for Dev Tools: http://0.0.0.0:5601/app/dev_tools
You can add data to Elasticsearch by sending JSON objects
(documents) to Elasticsearch over HTTP.
Whether you have structured or unstructured text, numerical data, or geospatial data,
Elasticsearch efficiently stores and indexes it in a way that supports fast searches.
We can use the Kibana Dev Tools console or any HTTP client to submit REST requests to Elasticsearch,
Use Elastic Agent to collect data from hosts or containers that you need to monitor.
Submit an HTTP post request that contains a JSON document:
POST /customer/_doc/1
{
"name": "John Doe"
}
This request automatically creates the customer index, adds a new document that has an ID
of 1
,
and stores and indexes the name
field.
The new document is available immediately from any node in the cluster. You can retrieve it with a GET request that specifies its document ID:
GET /customer/_doc/1
Instead of adding documents one at a time, you can use the _bulk
endpoint to add multiple documents in one request.
This minimizes network roundtrips and is significantly faster than adding documents one at a time.
Want to index some of your own data? You can upload data from a CSV, TSV, JSON file or use Elastic integrations to collect data from popular services and platforms like Nginx, AWS, and MongoDB. To check what’s available, select Add integrations on the Kibana home page.
POST /product/_bulk?pretty
{ "create":{ } }
{ "title": "Book", "price":205}
{ "create":{ } }
{ "title": "Super book", "price":999}
{ "create":{ } }
{ "title": "Pencil", "price":55}
{ "create":{ } }
{ "title": "Book with pencil", "price":455}
{ "create":{ } }
{ "title": "Paper", "price":345}
Indexed documents are available for search in near real-time.
To search for specific terms within a field, you can use a match query.
For example, the following request searches the title
field
to find products whose titles contain pencil
or book
:
GET /product/_search
{
"query": { "match": { "title": "pencil book" } }
}
To construct more complex queries, you can use a bool query to combine multiple query criteria. You can designate criteria as required (must match), desirable (should match), or undesirable (must not match).
For example, the following request searches the product index for items that have price
999,
but excludes items that have title
'Pencil':
GET /product/_search
{
"query": {
"bool": {
"must": [
{ "match": { "price": "999" } }
],
"must_not": [
{ "match": { "title": "Pencil" } }
]
}
}
}