Hi Abdon,
Thanks for the reply. I finally got a chance to pick the issue up again. Here is the output regarding the Product Prices bit from the query:
* "productPrices": {
* "properties": {
* "id": {
* "type": "text",
* "fields": {
* "keyword": {
* "type": "keyword",
* "ignore_above": 256}}},
* "priceForPriceGroups": {
* "properties": {
* "currency": {
* "type": "text",
* "fields": {
* "keyword": {
* "type": "keyword",
* "ignore_above": 256}}},
* "price": {
* "type": "double"},
* "priceBeforeDiscount": {
* "type": "double"},
* "priceGroupName": {
* "type": "text",
* "fields": {
* "keyword": {
* "type": "keyword",
* "ignore_above": 256}}},
* "priceGroupVATPercentage": {
* "type": "integer"},
* "priceWithVAT": {
* "type": "double"},
* "priceWithoutVAT": {
* "type": "double"},
* "productCatalogName": {
* "type": "text",
* "fields": {
* "keyword": {
* "type": "keyword",
* "ignore_above": 256}}},
* "vATValue": {
* "type": "double"}}},
"productId": {
"type": "text",
* "fields": {
* "keyword": {
* "type": "keyword",
* "ignore_above": 256}}}}},
Changed it to nested instead. It looks like this now:
"pricesForPriceGroups": {
"type": "nested",
"properties": {
"currency": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"price": {
"type": "double"
},
"priceBeforeDiscount": {
"type": "double"
},
"priceGroupName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"priceGroupVATPercentage": {
"type": "integer"
},
"priceWithVAT": {
"type": "double"
},
"priceWithoutVAT": {
"type": "double"
},
"productCatalogName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"vATValue": {
"type": "double"
}
}
},
And I am attempting to use a nested aggregation and ensure that I am getting the data only from a single price group:
return new SearchDescriptor<ProductBase>()
.Index(_indexName)
.From(0)
.Size(10000)
.Aggregations(ag => ag
.Terms("categories", t => t
.Field(p => p.Categories.Suffix("name").Suffix("keyword"))
.Size(100))
.Terms("certificates", term => term
.Field(field => field.Certificates.Suffix("keyword")))
.Terms("contents", term => term
.Field(field => field.Contents.Suffix("keyword")))
.Terms("type", term => term
.Field(field => field.Properties["Type"].Suffix("keyword")))
.Terms("function", term => term
.Field(field => field.Properties["Function"].Suffix("keyword")))
.Nested("nested", n => n
.Path(f => f.PricesForPriceGroups)
.Aggregations(agg => agg
.Filters("fil", fil => fil
.AnonymousFilters(fi => fi
.Bool(b => b
.Must(m => m
.Term(te => te
.Field(field => field.PricesForPriceGroups.Suffix("priceGroupName").Suffix("keyword"))
.Value(_currentPriceGroup.Name))))))
.Min("min", st => st
.Field(p => p.PricesForPriceGroups.Suffix("priceWithoutVAT")) )
But the inner aggregations are null and the values are also 0 or empty.
I also tried this:
...
.Nested("nested", n => n
.Path(f => f.PricesForPriceGroups)
.Aggregations(agg => agg
.Filters("fil", fil => fil
.AnonymousFilters(fi => fi
.Bool(b => b
.Must(m => m
.Match( ma => ma
.Field( field => field.PricesForPriceGroups.Suffix("priceGroupName").Suffix("keyword"))
.Query(_currentPriceGroup.Name))))))
.Min("min", st => st
.Field(p => p.PricesForPriceGroups.Suffix("priceWithoutVAT")) )
But it has the same result. Any input is appreciated.