Multi Search Terms NEST C #

I want to do a search matching multiple values ​​(an array of values) as follows:

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 this? I thought about the verge, but I do not understand how I can do this. The only way that works now is with the foreach iterator, which is not very efficient ...

Thank you for your help.

+7
c # elasticsearch nest
source share
2 answers

You can express several requests, for example:

 .Query(q=>q.Terms(t=>t.arg3, result1) && q.Terms(t=>t.arg1, value1)) 

Be sure to read the documentation when writing your queries to discover all the useful stuff that NEST offers.

+4
source share

Orelus , I would like to use your solution with

 .And( af=>af.Term(...), af=>af.Term(...) ) 

I don’t understand where this fits, here is an example of my idle 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) ) ) ) ) ) ); 
0
source share

All Articles