I have two indices with the following mapping(I will shortcut their mappings):
1) AccountType mapping:
elasticClient.CreateIndex("account", i => i
.Settings(s => s
.NumberOfShards(2)
.NumberOfReplicas(0)
)
.Mappings(m => m
.Map<AccountType>(map => map
.AutoMap()
.Properties(p => p
.Text(c => c
.Name(n => n.Name)
.Analyzer("standard")
)
.Text(c => c
.Name(n => n.Description)
.Analyzer("standard")
)
)
)
)
);
2) ProductType mapping:
elasticClient.CreateIndex("proudct", i => i
.Settings(s => s
.NumberOfShards(2)
.NumberOfReplicas(0)
)
.Mappings(m => m
.Map<ProductType>(map => map
.AutoMap()
.Properties(p => p
.Text(c => c
.Name(n => n.Title)
.Analyzer("standard")
)
.Text(c => c
.Name(n => n.Description)
.Analyzer("standard")
)
)
)
)
);
Now I have several things I need to get them clear:
1) First is it a good idea to have one index which in my case is account and has products as nested objects, but here for each time I want to update/add new product I have to re-index(update) the whole account document?
2) My second questions is: I want to have search functionality, so if the user search by typing in a textbox I would like to get best matches for both Accounts and Products(here I will search against product's title and description plus account's name and description then getting best matches) :
So here how to search against multiple indices using Nest ElasticSeach, or if it's not possible is it a good idea to get best matches from every index, then getting best matches from both results depending on score?
PS: Here is an example for searching inside product index:
var result = elasticClient.Search<ProductType>(s => s
.Size(10)
.Query(q => q
.MultiMatch(m => m
.Fields(f => f.Field(p => p.Title, 1.5).Field(p => p.Description, 0.8))
.Operator(Operator.Or)
.Query(query)
)
)
);