Hi,
I'm using Elasticsearch 1.5, here is a sample of what I'm trying to index:
{
"Id":"000000a6aOO4T2iA",
"CreatedDate":"2016-01-12T14:13:33.285Z",
"ModifiedDate":"2016-01-12T14:13:33.285Z",
"Segment":"not-applicable",
"TenantId":"101",
"Attributes":{
"PhoneNumber_1452608013247":"{"Id":"PhoneNumber_1452608013247","Name":"PhoneNumber","StrValue":"1452608013247","Description":"a nice PhoneNumber","MimeType":null}",
"FirstName_Shara":"{"Id":"FirstName_Shara","Name":"FirstName","StrValue":"Shara","Description":"a nice FirstName","MimeType":null}",
"LastName_Conor":"{"Id":"LastName_Conor","Name":"LastName","StrValue":"Conor","Description":"a nice LastName","MimeType":null}",
"PhoneNumber_145260801324722":"{"Id":"PhoneNumber_145260801324722","Name":"PhoneNumber","StrValue":"145260801324722","Description":"a nice PhoneNumber","MimeType":null}"
},
"PrimaryAttributes":{
"FirstName":"Shara",
"PhoneNumber":"1452608013247",
"LastName":"Conor"
},
"IndexationDate":"2016-01-12T14:13:33.309Z"
}
The Attribute object contains, keys that are made of type and StrValue, then inside the value there is a JSON doc that I'd like to map.
The goal is to be able to search either in PrimaryAttributes or in all Attribute StrValues that includes primary and non primary values. Types such as LastName or PhoneNumber are configurable by the end-user so I can't assume any value there.
Here is the resulting Lucene document I'd expect:
{
"Id":"000000a6aOO4T2iA",
"CreatedDate":"2016-01-12T14:13:33.285Z",
"ModifiedDate":"2016-01-12T14:13:33.285Z",
"Segment":"not-applicable",
"TenantId":"101",
"PrimaryAttributes.FirstName":"Shara",
"PrimaryAttributes.PhoneNumber":"1452608013247",
"PrimaryAttributes.LastName":"Conor",
"PhoneNumber":"1452608013247",
"PhoneNumber":"145260801324722",
"FirstName":"Shara",
"LastName":"Conor","IndexationDate":"2016-01-12T14:13:33.309Z"
}
I find very difficult to debug mappings, I'm using break points in Elasticsearch code, is there a better way?
I tried many different mapping, here is an example, but it does not work:
{
"Contact":
{
"dynamic": "true",
"properties":
{
"Id":
{
"type": "string",
"analyzer": "keyword"
},
"TenantId": { "type": "long", "analyzer": "keyword" },
"Segment": { "type": "string", "analyzer": "keyword" },
"CreatedDate": { "type": "date", "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "analyzer": "standard" },
"ModifiedDate": { "type": "date", "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "analyzer": "standard" },
"PrimaryAttributes": { "dynamic": "false", "type": "nested", "fields": { "EmailAddress": { "type": "string", "index": "analyzed", "analyzer": "standard" },
"{name}": { "type": "string", "index": "analyzed", "analyzer": "standard" } } } },
"dynamic_templates": [ { "ContactAttributes": { "path_match": "Attributes.*", "mapping": { "type": "nested", "properties": { "StrValue": { "type": "string", "index": "analyzed", "copy_to": "{name}.Name" },
"{name}": { "index": "no" } } } } } ]
}
}
Thank you for the help!
JHB