these operators are shortcuts for a BoolQuery (either should or must). The QueryContainerDescriptor is now called QueryDescriptor and the corresponding non-fluent class is just Query. The latter one still supports these operators, but for the descriptors they are not available at the moment.
You could either change your code to use Query instead of the descriptors, or probably even better (based on the code snippet you posted), keep building the individual queries for sessionKey and email, store then in a list and create the "container" in the very end using a single Query.Bool(...Must(queryList)).
The query approach would work but we will miss the strongly typed field name we get through the generic descriptors. I found a workaround for this using the Infer.Field for the corresponding class instead, but preferably we would continue to use the fluent descriptors.
I am not quite able to figure out how to implement the second approach you suggest here. Are you referring to the usage of:
at the moment it's kinda hard to mix fluent and object syntax.
Yes! The trick is to maintain a list of Action<QueryDescriptor<T>>> instead of just a list of QueryDescriptor<T>. Using this approach you can dynamically add or remove actions from the list, before crafting the final query descriptor that combines the sub-queries. Must is equivalent to && and Should is equivalent to ||.
var actions = new List<Action<QueryDescriptor<Person>>>()
{
x => x.Term(x => x.Field(p => p.FirstName)),
x => x.Term(x => x.Field(p => p.Email)),
};
var q = new QueryDescriptor<Person>().Bool(x => x.Must(actions.ToArray()));
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.