AI OnAI Off
You cannot use wildcards in UnifiedSearchFor directly as it will be interpreted as the char * and not the 'wildcard'. What you can do is create your own For extension that supports this:
public static IQueriedSearch<TSource, QueryStringQuery> WildcardFor<TSource>(
this ITypeSearch<TSource> search, string queryString)
{
return new Search<TSource, QueryStringQuery>(search, context =>
{
var query = new QueryStringQuery(searchQuery);
context.RequestBody.Query = query;
});
}
Thanks Henrick - works great :)
Just one little mistake on the seachQuery variable name, think it should be queryString
public static IQueriedSearch<TSource, QueryStringQuery> WildcardFor<TSource>(
this ITypeSearch<TSource> search, string queryString)
{
return new Search<TSource, QueryStringQuery>(search, context =>
{
var query = new QueryStringQuery(queryString); context.RequestBody.Query = query;
});
}
Hi
Best bets doesn't seem to work when this extension method is applied, have you noticed this too Adam?
/Fred
Is it possible to use wildcard or AnyWordBeginWith filter on the UnifiedSearchFor method?
I took a look at the elastic search documentation which says wildcard characters are can be used as * but adding this onto the end of the words I pass to UnifiedSearchFor() does not appear to work.
I can see there are example of performing wildcard and fuzzzy queries by Joel and Henirck but these are performed at a field level, not across all feilds when using UnifiedSearchFor() method.
Is this possible, or should it not be done because of the performance hit.
Thanks,
Adam