Elasticsearch: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
Line 25: Line 25:
</pre>
</pre>


== Create the index ==
== Create the index or table ==
Elasticsearch: [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings Create index API | Elasticsearch Guide [8.15] | Elastic]<ref>[https://opster.com/guides/elasticsearch/search-apis/elasticsearch-strings-keyword-vs-text-vs-wildcard/ Elasticsearch Keyword VS. Text - Strings Types Explained]</ref><ref>[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html Field data types | Elasticsearch Guide [8.15] | Elastic]</ref>
Elasticsearch: [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings Create index API | Elasticsearch Guide [8.15] | Elastic]<ref>[https://opster.com/guides/elasticsearch/search-apis/elasticsearch-strings-keyword-vs-text-vs-wildcard/ Elasticsearch Keyword VS. Text - Strings Types Explained]</ref><ref>[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html Field data types | Elasticsearch Guide [8.15] | Elastic]</ref>
<pre>
<pre>

Revision as of 15:45, 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

Elasticsearch: Create index API | Elasticsearch Guide [8.15 | Elastic][2][3]

PUT /MY_INXEX
{
  "mappings": {
    "properties": {
     "id": { "type": "keyword" },
      "field1": { "type": "text" }
    }
  }
}

MySQL MySQL :: MySQL 8.4 Reference Manual :: 15.1.20 CREATE TABLE Statement

CREATE TABLE MY_TABLE (
  id INT AUTO_INCREMENT PRIMARY KEY,
  field1 TEXT
) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

References