I want to get all members where field "username" contains substring e.g - "user" with the help of Lucene Wildcards.
Member's Username is "username"
"user" - not found
"rname" - not found
"usernam" - found
I used code below, but it seems that it works not in all cases;
string alias = "username";
IBooleanOperation op;
IQuery query;
var values = Value.Split(',');
if (values.Length > 0)
{
string searchQuery = $"({alias}:({string.Join("~ ", values)}~))";
op = query.And(op).NativeQuery(searchQuery);
}
I need something like in SQL: WHERE [username] LIKE '%user%'
Are you sure the alias of your member username is actually "username"? The alias for the built in member username (called "Login" in the backoffice) is "_umb_login", while that becomes "loginName" in the MembersIndex. Which is another point - remember to look in the MembersIndex and not ExternalIndex when looking for members.
In Examine wildcard is * and not ~ (as far as I understand). For fuzzy searches I'd even recommend giving RawQuery a try, like here: Umbraco Examine - querying issue
Also take a look at the example here, if you haven't already: https://our.umbraco.com/documentation/Reference/Searching/Examine/quick-start/#getting-the-content - it looks like you might have misunderstood something with the boolean operator?