NEST Query in lIst question

Hello, i am using NEST to query Elastic from my C# app and was wondering if there was a way to pass in a list of string to the term query?

I currently have something similar with SOLR (SolrQueryInList("FIELDNAME", array of terms)

I am currently doing this
var result = client.Search(s => s
.Size(0)
.Query(q => q
.Term(p => p.createdby, "USERID1") || q.Term(p => p.createdby, "USERID2") || q.Term(p => p.createdby, "USERID3"))

I would rather pass in a list of users since i have quite a few to pass into my query.

Is this possible?

Thanks,

what version of NEST and version of Elasticsearch are you targeting?

@forloop I am using NEST 2.1.1 with Elastic Search 2.2.0.

Thanks

You can use the Terms Query. Either

var result = client.Search<Document>(s => s
    .Query(q => q
        .Terms(t => t
           .Field(p => p.createdby)
           .Terms("USERID1", "USERID2", "USERID3")
        )
    )
);

or

var result = client.Search<Document>(s => s
    .Query(q => q
        .Terms(t => t
           .Field(p => p.createdby)
           .Terms<string>(new List<string>{ "USERID1", "USERID2", "USERID3" })
        )
    )
);

If passing some kind of IEnumerable<T> to Terms<T>(), I would recommend explicitly specifying the type of T as I have done above with string in the second example; In NEST 2.x prior to 2.1.0, not specifying the generic parameter type meant that the params T[] overload of Terms() was incorrectly called.

Awesome.. thank you very much