Elasticsearch: Difference between revisions
Jump to navigation
Jump to search
| Line 49: | Line 49: | ||
== Select | == Select all data from index or table == | ||
Elasticsearch<ref>[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html Get index API | Elasticsearch Guide [8.15] | Elastic]</ref> | Elasticsearch<ref>[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html Get index API | Elasticsearch Guide [8.15] | Elastic]</ref> | ||
| Line 63: | Line 63: | ||
FROM MY_TABLE | FROM MY_TABLE | ||
LIMIT 1000 | LIMIT 1000 | ||
</pre> | |||
or | |||
<pre> | |||
SELECT * | |||
FROM MY_TABLE | |||
</pre> | </pre> | ||
Revision as of 15:52, 15 October 2024
Count the number of documents
Elasticsearch: Count API | Elasticsearch Guide [8.15 Elastic]
GET /MY_INXEX/_count
MySQL MySQL :: MySQL 8.4 Reference Manual :: 5.3.4.8 Counting Rows
SELECT COUNT(*) FROM MY_TABLE
Truncate the index or table
Elasticsearch: Delete API | Elasticsearch Guide [8.15 | Elastic][1]
DELETE /MY_INXEX/
MySQL MySQL :: MySQL 8.4 Reference Manual :: 15.1.37 TRUNCATE TABLE Statement
TRUNCATE MY_TABLE
Create the index or table
PUT /MY_INXEX
{
"mappings": {
"properties": {
"id": { "type": "keyword" },
"field1": { "type": "text" }
}
}
}
MySQL[5]
CREATE TABLE MY_TABLE ( id INT AUTO_INCREMENT PRIMARY KEY, field1 TEXT ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Select all data from index or table
Elasticsearch[6]
GET /MY_INDEX/_search/?size=1000&pretty=true
MySQL[7]
SELECT * FROM MY_TABLE LIMIT 1000
or
SELECT * FROM MY_TABLE
References
- ↑ python - Truncate index in elasticsearch - Stack Overflow
- ↑ Create index API | Elasticsearch Guide [8.15 | Elastic]
- ↑ Elasticsearch Keyword VS. Text - Strings Types Explained
- ↑ Field data types | Elasticsearch Guide [8.15 | Elastic]
- ↑ MySQL :: MySQL 8.4 Reference Manual :: 15.1.20 CREATE TABLE Statement
- ↑ Get index API | Elasticsearch Guide [8.15 | Elastic]
- ↑ MySQL :: MySQL 8.4 Reference Manual :: 5.3.4.1 Selecting All Data