AI Hints
Home›Elasticsearch Tutorial›Kibana and Your First Requests
Elasticsearch · Lesson 8 of 120

Your First Request

Store it, find it.

⏱ 2 min read▶ Video at 7:09🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

Let's get a quick win. We'll store two products, and then search for one of them. No setup, no schema, just JSON in and results out.

  • Store two products
  • Search
  • Results

The first two requests store two products, with the IDs one and two. Refresh true makes them searchable straight away, and filter path keeps each answer short. Then we search names for the word tent. Run it. Both products were created, and the search found the tent, with a relevance score.

Dev Tools Consoletext
PUT products/_doc/1?refresh=true&filter_path=result
{ "name": "Basecamp 2-Person Tent", "price": 237.99 }

PUT products/_doc/2?refresh=true&filter_path=result
{ "name": "Storm Rain Jacket", "price": 129.99 }

GET products/_search?filter_path=hits.hits._score,hits.hits._source
{ "query": { "match": { "name": "tent" } } }
Output
# PUT products/_doc/1 201 Created
{"result": "created"}

# PUT products/_doc/2 201 Created
{"result": "created"}

# GET products/_search 200 OK
{
  "hits": {
    "hits": [
      {
        "_score": 0.6549,
        "_source": {
          "name": "Basecamp 2-Person Tent",
          "price": 237.99
        }
      }
    ]
  }
}

What just happened

We never created the index, or said which fields exist. Elasticsearch created the products index on the first PUT. It guessed a type for each field. And it indexed every word, ready to search.

keyvalue
Indexcreated automatically
Fieldstypes guessed
Wordsindexed for search
Resultfound in milliseconds

Summary

PUT stores a document, and GET_search finds it. Elasticsearch created the index and fields for us. Next, checking the health of the cluster.

Key takeaways
  • PUT a document
  • GET _search
  • Auto index
Next up: Cluster Health and _cat — is everything OK?