我正在嘗試使用該ElasticClient.Search方法進(jìn)行搜索,但無論我設(shè)置什么術(shù)語或搜索字段,我總是得到 0 個結(jié)果。這是我的 POCO 的結(jié)構(gòu):public class MyParent{ public MyChild MyChild { get; set; }}public class MyChild{ public string MyField { get; set; }}然后這是我的實際搜索代碼:string searchTerm = "myChild.myField";string searchValue = "C";Field searchField = new Field(searchTerm);ISearchResponse<MyParent> result = Client.Search<MyParent>(s => s.Query(q => q.Term(searchField, searchValue)));if (result != null && result.Documents != null && result.Documents.Count != 0){ ...}任何幫助表示贊賞!
1 回答

冉冉說
TA貢獻(xiàn)1877條經(jīng)驗 獲得超1個贊
發(fā)現(xiàn)問題了。我沒有設(shè)置索引!我將我的搜索代碼更改為這個并且它有效:
ISearchResponse<MyParent> result =
Client.Search<MyParent>(s =>
s.Index("my_index_").Query(q => q.Term(searchField, searchValue)));
- 1 回答
- 0 關(guān)注
- 247 瀏覽
添加回答
舉報
0/150
提交
取消