is it good have multi level fields in elasticsearch document?
if yes what how to search documents with nested fields
I didn't see documentation regarding on elasticsearch docshttps://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
Multi level I mean nested fields
{
"account_number": 0,
"balance": 16623,
"firstname": "Bradshaw",
"lastname": "Mckenzie",
"age": 29,
"gender": "F",
"address": {
"244 Columbus Place",
"employer": "Euron",
"email": {
"personal":"bradshawmckenzie@euron.com",
"work": "bradshawmckenzie@euron.com"
}
"city": "Hobucken",
"state": "CO"
}
}```
In about document address and email inner objects
Yes, it is completely fine to have multiple levels of objects.
However, your current JSON document is not valid. I assume it should be more like this.
{
"account_number": 0,
"balance": 16623,
"firstname": "Bradshaw",
"lastname": "Mckenzie",
"age": 29,
"gender": "F",
"address": "244 Columbus Place",
"employer": "Euron",
"email": {
"personal": "bradshawmckenzie@euron.com",
"work": "bradshawmckenzie@euron.com"
},
"city": "Hobucken",
"state": "CO"
}
To access inner objects, you can use dot notation. For example:
GET my-index/_search
{
"query": {
"match": {
"email.personal": "bradshawmckenzie@euron.com"
}
}
}
There are several ways of having "multiple levels" in Elasticsearch, there are pros and cons for each approach. The following article explains them well: https://www.elastic.co/blog/managing-relations-inside-elasticsearch
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.