ES provides near real time search capabilities.
Text: Use type as 'Text' when it requires full-text and relevancy search in documents.
Keyword: This is required when searching is based on exact value.Many operation like filtering, sorting, aggregation requires exact value.
Alisases:
- Switch transparently between one index and another on a running cluster
- Group multiple indices (for example,
last_three_months
)
- Create “views” on a subset of the documents in an index
Aliases gives the following:
Add/ Remove indices to aliases
POST /_aliases
{
"actions" : [
{ "remove" : { "index" : "test1", "alias" : "employee" } },
{ "add" : { "index" : "test2", "alias" : "employee" } }
]
}
POST /_aliases
{
"actions" : [
{ "add" : { "indices" : ["employee-primary", "employee-secondary"], "alias" : "employee" } }
]
}
Associating main and backup/old indexes/indices for a given context employee:
GET /sample-app-index-spec/metadata/employee
Create Index to metadata
PUT
/sample-app-index-spec/emp-metadata/employee
{
"context":"employee",
"main" :
"employee-version2",
"previous":
"employee-version1"
}
Get mapping :
GET employee/_mapping
GET employee-primary/_mapping
Get all aliases: GET _aliases, get _cat/aliases
Get all indices: GET _cat/indices
Dilete all indice: DELETE INDEX_NAME
"mappings": {
"employee": {
"preferredLocations": {
"properties": {
"city": {
"properties": {
"value": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
},
"currenltLocations": {
}
}
Note: depending upon properties type text/keyword/number query performance will vary.
#. To make element searchable it should available in the mapping document. so that it is getting indexed and query can be made as per the mapping. If the element is not going to be searchable the new element can be added without part of mapping
#. To make element searchable it should available in the mapping document. so that it is getting indexed and query can be made as per the mapping. If the element is not going to be searchable the new element can be added without part of mapping
No comments:
Post a Comment