-
Notifications
You must be signed in to change notification settings - Fork 25.4k
[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
Closed
[DOCS] Add Quick Start page #40903
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3460d85
[DOCS] Add Quick Start page
jrodewig ba8c049
[DOCS] Clean up console examples
jrodewig b72a9fd
Update docs/reference/quick-start.asciidoc
lcawl 5259473
[DOCS] Remove possessive modifiers on attributes. These could cause t…
jrodewig e0d2c95
[DOCS] Replace instances of future tense.
jrodewig f57b46c
[DOCS] Cleanup snippet comments to pass gradle tests
jrodewig 3148b72
[DOCS] Document unsupported order of operations for // TESTSETUP and …
jrodewig 86d4d7c
[DOCS] Remove unneeded escape character
jrodewig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
|
||
. 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] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.