1
我使用嵌套執行相同的請求,並直接在ElastichSearch中執行。 當我看到直接請求時,有多少個文檔匹配請求。如何獲取使用Nest找到的文檔總數?
"hits":
{
"total": 1640,
"max_score": 1,
"hits": [...]
}
我的查詢:
var search = client.Search<RCompany>(s => s.Index("MyIndex")
.Query(qq => qq
.Filtered(m => m.Filter(f => f.Bool(b => b
.Must(
a => a.Term(z => z.Company.Code, param1),
a => a.Terms(z => z.Company.Id, param2),
a => a.Terms(z => z.Company.Field1.Id, param3)
)))
.Query(b => b.Bool(q => q.Should
(n => n.Match(a => a.OnField(d => d.Company.Field2).Query(param5).Operator(Operator.And)),
n => n.Match(a => a.OnField(d => d.Company.Field3).Query(param5).Operator(Operator.And)),
n => n.Match(a => a.OnField(d => d.Company.Field4).Query(param5).Operator(Operator.And)),
n => n.Match(a => a.OnField(d => d.Company.Field5).Query(param5).Operator(Operator.And))
)))))
.Size(10)
.SortDescending(n => n.DtCreate));
多少文檔適合請求,利用鳥巢我怎麼能找到?
謝謝,格雷格使用所提出的方法計數!提出了幾個要求,但總的來說一直是10號,這與我的尺寸一致。這是誤導。 – helvar 2014-09-25 14:26:28
'Size'和'Total'是兩個不同的東西。 'Size'表示返回請求結果的數量(缺省值爲10),並與'From'(從索引開始的偏移量)一起使用。這些對分頁很有用。另一方面,「Total」是與查詢匹配的文檔的實際數量。 – 2014-09-25 17:36:06