elasticsearch - do we need to create index specifically in elasticsearch?
问题描述
I'm quite new to elasticsearch and I know index in elasticsearch has 2 meanings, it either means the logical namespace that maps to shards in a node or index some data as that we do in relational database management systems. So normally in SQL I would use 'Create index' to create a single or composite index on a field or multiple fields, how do I do that in elasticsearch or does elasticsearch do the index (verb) automatically that can improve search efficiency?
解决方案
You were right that the index in elasticsearch internally mapped to shards and replicas but you are getting confused with the naming/meaning of an index wrt to RDBMS(in RDBMS its created to increase the search efficiency).
While in Elatsicsearch, an index contains a mapping(where you define various fields, their data-type, and analyzer), for more info refer to Mapping in elasticsearch
Now, when you define a field in elasticsearch it accepts a few parameters and one of which param is also called index, which according to the same official doc is
The index option controls whether field values are indexed. It accepts true or false and defaults to true. Fields that are not indexed are not queryable.
This means, the field will be part of Elasticsearch inverted index, which is used to query/search the data, and obviously without this option you will not be able to search this particular field and as this is part of the inverted index(faster data structure to increase search performance), you will implicitly get the better search performance :)
As mentioned in the official doc default value of index param is true, so to answer your question, you don't need to define the index specifically in Elasticsearch.
推荐阅读
- docker - 由于 RAM 中断,Docker Compose WSL2 就像一盏圣诞灯
- python - 将“类似地图”的可调用对象传递给 scipy 的差分进化
- c++ - Arduino MySQL 连接器 - SELECT 语句返回 NULL
- php - Laravel Linux 存储:链接不会保留存储的内容
- java - 文本对象未显示在 javafx 场景窗口对象中
- python - 如何在函数事件中使用 tix 气球?
- android - AbsoluteToLocal 在 Android 上不像在 Windows 上那样工作
- javascript - 隐藏制表符单元格上的标题标签
- python - 如何将 HTML 转换为 Python 字典列表
- spring-boot - 嗨,我正在尝试将 DXF 解析库 Kabeja 与 Spring Boot 一起使用