Skip to content

[DOCS] Add Quick Start page #40903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ for its modifiers:
"figures out" the path. This is especially useful for making sweeping
assertions like "I made up all the numbers in this example, don't compare
them" which looks like `// TESTRESPONSE[s/\d+/$body.$_path/]`.
* You can't use `// TESTRESPONSE` immediately after `// TESTSETUP`. Instead,
consider using `// TEST[continued]` or rearrange your snippets.
* `// TESTRESPONSE[_cat]`: Add substitutions for testing `_cat` responses. Use
this after all other substitutions so it doesn't make other substitutions
difficult.
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

include::../Versions.asciidoc[]

include::quick-start.asciidoc[]

include::getting-started.asciidoc[]

include::setup.asciidoc[]
Expand Down
293 changes: 293 additions & 0 deletions docs/reference/quick-start.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
[[quick-start]]
== Quick Start

One of the best ways to learn about Elasticsearch is to use it. This page walks
you through steps for running {es} and doing common tasks. By the end, you
should know how to:

* Add your data to {es}
* Run basic searches
* Update or delete data in {es}

Let's get started!

[float]
=== Install and run {es}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section reminds me a lot of https://www.elastic.co/guide/en/elastic-stack-get-started/master/get-started-elastic-stack.html#install-elasticsearch

If you agree, perhaps we can combine the content and just re-use it in both places (e.g. via a tagged region). I'm happy to help with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds great! I'll go ahead and add a tag to this section. I'll look into combining the two docs as part of another issue/PR.

. Visit https://www.elastic.co/downloads/elasticsearch and download the
appropriate archive file for your operating system.

. Extract the downloaded file.
+
Once you've extracted the file, {es} is ready to run.

. In your terminal, navigate to the newly extracted elasticsearch-{version}
folder.

. From the elasticsearch-{version} folder, run `bin/elasticsearch`. If using
Windows, run `bin\elasticsearch.bat` instead.

If all went well, you should see {es} logs in your terminal window.
Congratulations, you've started {es}!

To stop {es}, you can press `Ctrl + C` in this terminal window. You'll want
to open a new terminal window for the rest of these steps.

[float]
=== How to talk to {es}
While you can interact with {es} in many ways, the examples on this page
use the {es} REST API. The REST API offers a few advantages:

* You can talk to {es} using `curl` commands in your terminal.
* You can use standard HTTP request methods, like `GET`, `POST`, `PUT`, and `DELETE`.
* Responses from the REST API provide standard HTTP status codes, like `200 OK`
or `400 Bad Request`. These codes can be helpful when diagnosing a problem or
figuring out if a request succeeded.

[float]
=== Index a document

{es} stores data as JSON objects called documents. When adding a new document,
you must assign it to a collection called an _index_. Usually an index contains
documents of a similar type, like customer profiles or products in a catalog.

The index not only stores your documents but makes them searchable. Indices are
so important that adding new documents to {es} is called _indexing_.

To keep your data organized, each document in an index requires a unique ID. You
can provide this ID when you index a document or let {es} generate one for
you.
[float]
==== Provide a document ID

To index a document with a specific ID, use the PUT method with the
<<docs-index_, index API>>.

This example command adds a document with an ID of `1` to the `customer` index.
This command also creates the `customer` index if it doesn't already exist.

[source, js]
--------------------------------------------------
PUT /customer/_doc/1
{
"firstname": "Amber",
"lastname": "Duke",
"age": 32,
"employer": "Pyrami"
}
--------------------------------------------------
// CONSOLE

You can confirm {es} used your ID by checking the `_id` field of the response.
Here's an example response, formatted to be more readable.

[source, js]
--------------------------------------------------
{
"_index" : "customer",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
--------------------------------------------------
// TESTRESPONSE[s/yDWh7WkBJ8uiWiWqEEaF/$body._id/]
// TESTRESPONSE[s/"_seq_no" : 0/"_seq_no" : $body._seq_no/]

[float]
==== Autogenerate a document ID

To add a document without providing an ID, use the POST method with the
<<docs-index_, index API>>. {es} automatically generates an ID for the
document.

This example command adds a document to `customer` index. This command
also creates the `customer` index if it doesn't already exist.

[source, js]
--------------------------------------------------
POST /customer/_doc
{
"firstname": "Dale",
"lastname": "Adams",
"age": 48,
"employer": "Geekfarm"
}
--------------------------------------------------
// CONSOLE
// TEST[continued]

{es} provides the generated ID in `_id` field of the response. Here's an
example response, formatted to be more readable.

[source, js]
--------------------------------------------------
{
"_index" : "customer",
"_type" : "_doc",
"_id" : "yDWh7WkBJ8uiWiWqEEaF",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
--------------------------------------------------
// TESTRESPONSE[s/yDWh7WkBJ8uiWiWqEEaF/$body._id/]
// TESTRESPONSE[s/"_seq_no" : 0/"_seq_no" : $body._seq_no/]

[float]
=== Run a search

Now that you have some documents stored in Elasticsearch, you can fetch
and search your data.

[float]
==== Get a document by ID

To get a document based on its ID, use the <<docs-get, get API>>.

This example returns the document with an ID of `1` in the
`customer` index.

[source, js]
--------------------------------------------------
GET /customer/_doc/1
--------------------------------------------------
// CONSOLE
// TEST[continued]

[float]
==== URI search
For simpler test searches, you can use the {es} <<search-search, search API>>
with query-string parameters. This is also called <<search-uri-request>>.

This example performs a URI search for documents with an employer of
`Geekfarm` in the `customer` index.

[source, js]
--------------------------------------------------
GET /customer/_search?q=employer:Geekfarm
--------------------------------------------------
// CONSOLE
// TEST[continued]

[float]
==== Fully-body search
For more complex queries or to run {es} in production, you'll want to use
full-body search. With full-body search, you send search criteria to {es} as a
JSON object in the body of your API requests. You can also use the {es}
<<query-dsl>> to filter results or combine queries. It's flexible and powerful!

This example performs a full-body search for documents that match the
following criteria in the `customer` index:

* Last name of `Adams`
* Age greater than `30`

[source, js]
--------------------------------------------------
GET /customer/_search
{
"query" : {
"bool" : {
"must" : {
"match" : {
"lastname" : "Adams"
}
},
"filter" : {
"range" : {
"age" : { "gt" : 30 }
}
}
}
}
}
--------------------------------------------------
// CONSOLE
// TEST[continued]

[float]
=== Update a document

To update part of an existing document, use the <<docs-update, update API>>.

This example updates the document with an ID of `1` in the
`customer` index.

[source, js]
--------------------------------------------------
POST /customer/_doc/1/_update
{
"doc" : {
"employer" : "Geekfarm"
}
}
--------------------------------------------------
// CONSOLE
// TEST[continued]

[float]
=== Replace a document

To replace an entire document, use the <<docs-index_, index API>> with the PUT
method. Provide the ID of the document you'd like to replace.

This example replaces the document with an ID of `1` in the
`customer` index.

[source, js]
--------------------------------------------------
PUT /customer/_doc/1
{
"firstname": "Nanette",
"lastname": "Bates",
"age": 43,
"employer": "Quility"
}
--------------------------------------------------
// CONSOLE
// TEST[continued]

[float]
=== Delete a document

To delete a document by ID, use the <<docs-delete, delete API>>.

This example deletes the document with an ID of `1` in the `customer`
index.

[source, js]
--------------------------------------------------
DELETE /customer/_doc/1
--------------------------------------------------
// CONSOLE
// TEST[continued]


[float]
=== Delete an index

To delete an entire index, use the <<indices-delete-index, delete index API>>.
When you delete an index, all documents in that index are also deleted.

This example deletes the `customer` index.

[source, js]
--------------------------------------------------
DELETE /customer
--------------------------------------------------
// CONSOLE
// TEST[continued]