What I'm trying to do is create an input field that, as you type, it will search for users who follow you, based on the typed username and/or name.
I'm trying to use SOLR because it's fast and I'm unable to use MySQL's LIKE feature, but I'm running into issues with the number of values that I can pass to the SOLR query (e.g. user_id:(1,2,3,5,etc)
). SOLR apparently has a limit on the number of values you can pass, and I need this solution to not be limited.
As of right now my SOLR index includes username
, name
, and user_id
. I was then passing a list of previously collected follower_ids
to the query.
Any ideas on how to make this work?
UPDATE: As suggested in the comments of increasing the # of OR clauses... this really isn't a good solution as it will cause future problems.
I had the same issue of too many boolean clauses exception in solr. I had the acl ids(access control list) which are in more numbers so the query get too long.
Steps I have taken to overcome the issue is
Increase the maxBooleanCLauses
Used the in the filter query as &fq=acl:(id1 or id2...)
If the count of acl is greater than 8000 then i am sending multiple request with the below logic
StringBuilder queryString = new StringBuilder(5000); if (acls.length > 8000) { Integer aclCounter = 0; long requestCnt = Math.round(Math.ceil((acls.length / 8000.0))); for (int i = 0; i < requestCnt; i++) { queryString = new StringBuilder(acls.length * 10); queryString.append("&fq=acl:("); for (int j = 0; j < 8000 && aclCounter < acls.length; aclCounter++, j++) { queryString.append(acls[aclCounter]).append(APPEND_OR); } queryString.replace(queryString.length() - 4, queryString.length(), ")"); } }
I hope this would give a idea to resolve your issue.