Created
May 26, 2020 23:03
-
-
Save JimBobSquarePants/f07c60bd281614bf3f018de8c595c7ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a query where the result must match or contain the given query | |
// and the subset of properties and filters. | |
descriptor.Query( | |
q => q.Bool( | |
b => b.Must( | |
mu => | |
mu.MultiMatch( | |
m => m.Fields(propertyExpressions) // Search within these properties or all. | |
.Query(searchTerm) // For this query | |
.Operator(Operator.Or))) // In any of the properties. | |
.Filter(filters))); // Further filter results. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure I 100% understand, but I think you want to know how to augment with
filters
? One way I've done this in the past with the fluent syntax is to split out the building of query parts into separate methods. For example, in Linqpad with 7.7.0,Another way would be to start with a
QueryContainer
and use the overloaded operators onQueryContainer
to combine queries. Using the previous example, the following would build the same querywhich is
Note that the term query on
categories.name
doesn't care if the field is a single value or multiple value. In the case of multiple values, only one value has to match.The search result in both cases is