user23903
user23903

Reputation: 9

Case insensitive autocomplete search (using java, javascript, jquery)

I have an autocomplete search which is working, but however the problem is that it is case sensitive. I have to type it in the exact format to retrieve the search results.

How do I make it case insenstive? I have searched but cant seem to find solution relating to my specific situation. I am using json for passing data to javascript.

Below is my respective line of code in java for matching the query string. I am using the contains() method and finder from ebean play framework.

List<Team> teams = Team.find.where().contains("name", query).findList();

Any help is much appreciated. thanks!

Upvotes: 0

Views: 1139

Answers (1)

Runcorn
Runcorn

Reputation: 5224

I am not familiar with ebean , But i think using case insensitive contains will work using icontains,

List<Team> teams = Team.find.where().icontains("name", query).findList();

icontains

public static Expression icontains(String propertyName, String value)

Case insensitive Contains - property like %value%. Typically uses a lower() function to make the expression case insensitive.

Upvotes: 3

Related Questions