I'm trying to create an SQL-query similar to this:
(type1 OR type2) AND (cityname1 OR cityname2)
I've come up with something like this.
But this seems to result in a similar to this:
... AND type1 OR type2 AND cityName1 OR cityName2
Which gives me the wrong results. Any ideas?
I've just come across your question, and for this specific requirement, you have to build custom filters. You can try an example like this:
// Build the first level filter
var level1Filter = _searchClient.BuildFilter<T>();
// Build the second level filter
var level2FilterA = _searchClient.BuildFilter<T>();
level2FilterA = level2FilterA.And(x => <<your filter expression>>);
level2FilterA = level2FilterA.Or(x => <<your filter expression>>);
var level2FilterB = _searchClient.BuildFilter<T>();
level2FilterB = level2FilterB.And(x => <<your filter expression>>);
level2FilterB = level2FilterB.Or(x => <<your filter expression>>);
// Combine the two second level filters A & B to the first level filter
level1Filter = level1Filter.And(t => level2FilterA);
level1Filter = level1Filter.And(t => level2FilterB);
// Apply the first level filter to your query
query = query.Filter(level1Filter );
If you use Typed Search, then the generic T here is your strong typed model, and if you use Unified Search, then T should be of type ISearchContent.
Basically it is to build nested filters, so you will have the effect just like the parentheses :)