Reputation: 1397
I have a query where I want to have two clauses: one for .MultiMatch
and one for .Wildcard
. The wildcard is independent of the multimatch.
I can get them both working separately, but not together. The current error message in Visual Studio has the Wildcard
word underlined and says the following:
Querycontainer does not contain a definition for 'Wildcard'...
Here is the code I am trying to implement. I have tried putting .Wildcard
and .MultiMatch
in separate .Should
pieces but to no avail.
.Query(q => q
.Bool(b => b
.Should(m => m
.MultiMatch(ma => ma
.Fields(f => f.Field("_id")
.Field("elements.location.city")
.Field("ticket_number")
)
.Query(query)
)
.Wildcard(c => c
.Field("name").Value(query.ToLower() + "*")
)
)
)
)
The query
you see on line 8 is passed into this function as an argument.
As stated above, line 10 is the issue at hand as the Query container does not know what to do with Wildcard.
Any and all input is appreciated.
Upvotes: 0
Views: 1072
Reputation: 15559
It depends what boolean condition you want between the MultiMatch
and Wildcard
queries?
For example here, I am looking for records which satisfy both MultiMatch
AND WildCard
queries:
.Query(q => q
.Bool(b => b
.Must(m => m
.MultiMatch(mm => mm
.Fields(f => f.Field("FieldName"))
.Query("MyKeyword")
), wc => wc
.Wildcard(c => c
.Field("FieldName")
.Value("*Something*")
)
)
)
));
If you want to OR them, use Should
instead of Must
: see Bool Query Usage
Upvotes: 1