Reputation: 1451
I have the following documents:
fName : "Samuel",
sName : "Erick Jameson"
I want to return the user if the search is by Samuel, Erick, Jameson, Erick Jameson, Samuel Erick etc.
Basically if any word exist in the fName or sName, I want to return it. For now, I have the following query:
Function.lower(Expression.property("fName")).like(Expression.string("%" + searchTermLC + "%"))))
.or((Expression.property("lName").like(Expression.string("%" + searchTermLC + "%")));
my search results are:
Samuel found
Erick found
Jameson found
Erick Jameson found
the following are not found:
Samuel Erick
Erick Samuel
Samuel Jameson
...
what query would do that?
Upvotes: 0
Views: 29
Reputation: 24
There are a few mistakes noted in your query above:
I assume when you did your own test, the query syntax was right otherwise you would not have gotten any results.
The results you got are as expected for like
operator. If you want the query to include:
Samuel Erick
Erick Samuel
Samuel Jameson
in your results, you can try the In
Operator.
Upvotes: 0