[英]how to add dynamic facets in Elasticsearch and Nest
我有電影和音樂數據庫。 根據用戶是看電影還是聽音樂,需要改變方面。
我嘗試使用.OnFields(string [])傳入數組(根據電影/音樂而變化),但出現錯誤。
這是我使用的代碼會產生錯誤。 我想念什么?
string[] facetFields = new []{"genres","format","decades","price"};
var searchResult = client.Search<MyData>(s => s
.MatchAll()
.FacetTerm(t => t
.OnFields(facetFields)
.Order(TermsOrder.term)
.AllTerms()
));
錯誤是:
"Couldn't infer name for facet of type TermFacetDescriptor`1"
找到了答案。 您必須這樣命名構面(我知道但不確定在哪里)...
請參閱下面的“ MyFacet” ...
var searchResult = client.Search<MyData>(s => s
.MatchAll()
.FacetTerm("MyFacet", t => t
.OnFields(facetFields)
.Order(TermsOrder.term)
.AllTerms()
));
如果在文檔的某處-有人可以指出我嗎?
謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.