Consider this very basic T-SQL query:
select * from Users
where FirstName like '%dm0e776467@mail.com%'
or LastName like '%dm0e776467@mail.com%'
or Email like '%dm0e776467@mail.com%'
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": "dm0e776467@mail.com" } }, { "wildcard": { "lastName": "dm0e776467@mail.com" } }, { "wildcard": { "email": "dm0e776467@mail.com" } }
] } } }The Multimatch way (returns anything where mail.com is present)
{ "query": { "multi_match": { "query": "dm0e776467@mail.com", "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": ""dm0e776467@mail.com"", "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?