Consider this very basic T-SQL query:
select * from Users
where FirstName like '%[email protected]%'
or LastName like '%[email protected]%'
or Email like '%[email protected]%'
How can I write this in Lucene?
I have tried the following:
The query way (does not work at all, no results):
{ "query": { "bool": { "should": [ { "wildcard": { "firstName": "[email protected]" } }, { "wildcard": { "lastName": "[email protected]" } }, { "wildcard": { "email": "[email protected]" } }
] } } }The Multimatch way (returns anything where mail.com is present)
{ "query": { "multi_match": { "query": "[email protected]", "fields": [ "firstName", "lastName", "email" ] } } }
A third attempt (returns expected result, but if I only insert "mail", then no results are returned)
{ "query": { "query_string": { "query": ""[email protected]"", "fields": [ "firstName", "lastName", "email" ], "default_operator": "or", "allow_leading_wildcard": true } } }
It seems to me as there is no way to force Elasticsearch to force a query to use the input string as ONE substring?