多条搜索NEST C# [英] Multi Terms search NEST C#
本文介绍了多条搜索NEST C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要像这样搜索匹配多个值(一个数组):
I want to do a search matching multiple values ( an array of values ) like this :
var result1 = _client.Search<type1>(s => s
.Fields(f => f.trip_id)
.Query(q => q
.Terms(t => t.arg1, value1)).Take(_allData))
.Documents.Select(d => d.arg2).ToArray();
var result2 = _client.Search<type2>(s => s
.Query(q => q
.Terms(t => t.arg3, result1))
.Take(_allData)
).Documents.Select(s => s.ar3).ToList();
我该怎么办?我正在考虑方面,但我看不到我能做什么。
现在唯一可行的方法是使用一个 foreach
迭代器,这不是真的有效...
How can I do ? I was thinking about facets but I don't see how I can do it.
The only way for now that works is with a foreach
iterator which is not really effective...
感谢您的帮助。
推荐答案
您可以这样表达多个查询:
You can express multiple queries like so:
.Query(q=>q.Terms(t=>t.arg3, result1) && q.Terms(t=>t.arg1, value1))
请务必阅读撰写查询的文档,以发现NEST提供的所有好东西。
Be sure to read the documentation on writing queries to discover all the good stuff NEST has to offer.
这篇关于多条搜索NEST C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文