[英]Multi Terms search 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();
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... 现在唯一可行的方法是使用一个不真正有效的foreach
迭代器。
Thanks for your help. 谢谢你的帮助。
You can express multiple queries like so: 您可以这样表达多个查询:
.Query(q=>q.Terms(t=>t.arg3, result1) && q.Terms(t=>t.arg1, value1))
Be sure to read the documentation on writing queries to discover all the good stuff NEST has to offer. 确保阅读有关编写查询的文档,以发现NEST必须提供的所有优点。
Orelus , I'd like to use your solution with Orelus ,我想将您的解决方案用于
.And( af=>af.Term(...), af=>af.Term(...) )
I don't understand where this fits, here's an example of my non-working filter 我不知道这适合哪里,这是我的无效过滤器的示例
var results = client.Search<music>(s => s
.Query(q => q
.Filtered(f => f.
Filter(b => b.Bool(m => m.Must(
t => t
.Term(p => p.artist, artist)
&& t.Term(p2 => p2.year, year)
)
)
)
)
)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.