Arrays are supported out of the box by Elasticsearch and they don't need a specific mapping. You simply need to map the SubDocuments
field as an object
(or nested
object) and then the Title
field as a multi-field in that object.
{
"your_type" : {
"properties" : {
"ID" : {"type" : "long"},
"Title" : {"type" : "string"},
"Content" : {"type" : "string"},
"SubDocuments" : {
"properties" : {
"Title" : {
"type" : "string",
"fields": {
"raw": {
"type" : "string",
"index" : "not_analyzed",
}
}
}
}
}
}
}
}
It is worth noting that if you envision to add other fields to SubDocuments
and you need to query on those SubDocuments
fields, it might be wiser to map SubDocuments
as nested
type, like this:
{
"your_type" : {
"properties" : {
"ID" : {"type" : "long"},
"Title" : {"type" : "string"},
"Content" : {"type" : "string"},
"SubDocuments" : {
"type": "nested", <---- add this
"properties" : {
"Title" : {
"type" : "string",
"fields": {
"raw": {
"type" : "string",
"index" : "not_analyzed",
}
}
}
}
}
}
}
}
Then, in your documents, SubDocuments.Title
will be the field containing the analyzed variation and SubDocuments.Title.raw
will be another field containing the exact and non-analyzed string value.