c# - Lambda query in NEST elastic search to have array of filters and values -


from 2 arrays filter[] , value[] hold filter names , filter values

i need generate dynamic lambda query applying array of filters , values on it.

something similar this, apply array values dynamically.

var searchresults = client.search<job>(s => s.type("job")                                .size(size)                                .filter(f =>                                f.term(filter[0], value1[0]) ||                                f.term(filter[1], value[1]))                               ); 

awaiting suitable answer !!

you need create bool should filter , pass array of filtercontainer objects can generated dynamically. i've written small code snippet build nest query per requirements.

var filter = new list<string> { "field1", "field2" }; var value = new list<string> { "value1", "value2" };  var fc = new list<filtercontainer>(); (int = 0; < 2 /* size of filter/value list */; ++i) {     fc.add(filter<string>.term(filter[i], value[i])); }  var searchresults = client.search<job>(s => s     .type("job")     .size(size)     .filter(f => f         .bool(b => b             .should(fc.toarray())))); 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -