I am not able to search on nested data which is a list of addresses for contacts,
Expected: If i type anything directly related to contacts(FirstName, LastName, CompanyName1 etc) i am getting search results
If i type any of the text related to address, i expect the contact related to that address should show
the Addresses here is list of addresses related to that contact.
please suggest me for any workaround.
meta data from elastic search head:
index: "contacts",
type: "GetContactViewModel",
id: "63c6f419-c30a-4afc-b4e1-8cacc4bc0d65",
version: 1,
score: 1,
source: {
"Xmin": 2965,
"Id": "63c6f419-c30a-4afc-b4e1-8cacc4bc0d65",
"Type": "Company",
"SalutationId": "a29dd803-419b-4330-b5cd-e316ac50cb6f",
"Description": "",
"FirstName": "Shruthi",
"LastName": "Py",
"MiddleName": "ma",
"Position": "",
"CompanyName1": "Trimble",
"CompanyName2": "",
"Reference1": "",
"Reference2": "",
"Analysis1": "",
"Analysis2": "",
"Inactive": false,
"Addresses": [
{
"Xmin": 2965,
"Id": "9783ed82-362c-44e4-a2bf-98b6d8c965d6",
"ContactId": "63c6f419-c30a-4afc-b4e1-8cacc4bc0d65",
"AddressTypeId": "82dda8a0-1dcf-44ce-853f-a81b88ffc410",
"Format": "GB",
"AddressLine1": "GANDHI",
"AddressLine2": "VIDHI",
"AddressLine3": "",
"AddressLine4": "",
"AddressLine5": "",
"AddressLine6": "",
"AddressLine7": "",
"AddressLine8": ""
}
],
"Connections": null,
"CategoryLinks": null
}
C# code for mapping
public override Fields Fields
{
get
{
return Infer.Field<GetContactViewModel>(e => e.FirstName)
.And(Infer.Field<GetContactViewModel>(e => e.LastName))
.And(Infer.Field<GetContactViewModel>(e => e.Position))
.And(Infer.Field<GetContactViewModel>(e => e.CompanyName1))
.And(Infer.Field<GetContactViewModel>(e => e.CompanyName2))
.And(Infer.Field<GetContactViewModel>(e => e.Reference1))
.And(Infer.Field<GetContactViewModel>(e => e.Reference2))
.And(Infer.Field<GetContactViewModel>(e => e.Analysis1))
.And(Infer.Field<GetContactViewModel>(e => e.Analysis2))
.And(Infer.Field<GetContactViewModel>(e => e.Addresses.First().AddressLine1))
.And(Infer.Field<GetContactViewModel>(e => e.Addresses.First().AddressLine2))
.And(Infer.Field<GetContactViewModel>(e => e.Addresses.First().AddressLine3))
.And(Infer.Field<GetContactViewModel>(e => e.Addresses.First().AddressLine4))
.And(Infer.Field<GetContactViewModel>(e => e.Addresses.First().AddressLine5))
.And(Infer.Field<GetContactViewModel>(e => e.Addresses.First().AddressLine6))
.And(Infer.Field<GetContactViewModel>(e => e.Addresses.First().AddressLine7))
.And(Infer.Field<GetContactViewModel>(e => e.Addresses.First().AddressLine8))
.And(Infer.Field<GetContactViewModel>(e => e.Connections.First().Data));
}
}
protected override Func<MappingsDescriptor, IPromise<IMappings>> GetMappings()
{
return md => md
.Map<GetContactViewModel>(m => m
.AutoMap()
.Properties(pd => pd
.Keyword(kpd => kpd.Name(e => e.Id).Index(false))
.Keyword(kpd => kpd.Name(e => e.SalutationId).Index(false))
.Number(kpd => kpd.Name(e => e.Xmin).Type(NumberType.Integer).Index(false))
.Boolean(kpd => kpd.Name(e => e.Inactive).Index(false))
.Keyword(kpd => kpd.Name(e => e.Type).Index(false))
.Text(kpd => kpd.Name(e => e.Description).Index(false))
.Nested<GetCategoryLinkViewModel>(n => n
.Name(c => c.CategoryLinks)
.AutoMap()
.Properties(npd => npd
.Keyword(kpd => kpd.Name(cl => cl.Id).Index(false))
.Keyword(kpd => kpd.Name(cl => cl.ContactId).Index(false))
.Keyword(kpd => kpd.Name(cl => cl.CategoryId).Index(false))
)
)
.Nested<GetAddressViewModel>(n => n
.Name(c => c.Addresses)
.AutoMap()
.Properties(npd => npd
.Number(kpd => kpd.Name(a => a.Xmin).Type(NumberType.Integer).Index(false))
.Keyword(kpd => kpd.Name(a => a.Id).Index(false))
.Keyword(kpd => kpd.Name(a => a.AddressTypeId).Index(false))
.Keyword(kpd => kpd.Name(a => a.ContactId).Index(false))
.Keyword(kpd => kpd.Name(a => a.Format).Index(false))
)
)
.Nested<GetConnectionViewModel>(n => n
.Name(c => c.Connections)
.AutoMap()
.Properties(npd => npd
.Number(kpd => kpd.Name(c => c.Xmin).Type(NumberType.Integer).Index(false))
.Keyword(kpd => kpd.Name(c => c.Id).Index(false))
.Keyword(kpd => kpd.Name(c => c.ConnectionTypeId).Index(false))
.Keyword(kpd => kpd.Name(c => c.ContactId).Index(false))
.Text(kpd => kpd.Name(c => c.Code1).Index(false))
.Text(kpd => kpd.Name(c => c.Code2).Index(false))
)
)
)
);
}