- Elasticsearch 7.0 Cookbook(Fourth Edition)
- Alberto Paro
- 269字
- 2021-06-24 14:52:02
How it works...
Elasticsearch speaks native JSON, so every complex JSON structure can be mapped into it.
When Elasticsearch is parsing an object type, it tries to extract fields and processes them as its defined mapping. If not, it learns the structure of the object using reflection.
The most important attributes for an object are as follows:
- properties: This is a collection of fields or objects (we can consider them as columns in the SQL world).
- enabled: This establishes whether or not the object should be processed. If it's set to false, the data contained in the object is not indexed and it cannot be searched (default true).
- dynamic: This allows Elasticsearch to add new field names to the object using a reflection on the values of the inserted data. If it's set to false, when you try to index an object containing a new field type, it'll be rejected silently. If it's set to strict, when a new field type is present in the object, an error is raised, skipping the index process. The dynamic parameter allows you to be safe about changes in the document structure (default true).
- include_in_all: This adds the object values to the special _all field (used to aggregate the text of all document fields) (default true).
The most used attribute is properties, which allows you to map the fields of the object in Elasticsearch fields.
Disabling the indexing part of the document reduces the index size; however, the data cannot be searched. In other words, you end up with a smaller file on disk, but there is a cost in functionality.