Hi all!
I'm having a strange problem. I'm using Lucene for searching objects over an Index knowing over 1 million records.
I use a richFaces suggestion box. The object i'm searching for is an object with 3 fields.
"firstName","lastName","taxCode". (Person.java)
My suggestion box works but when i restrict the search like this:
i'm searching for a person named "Martin Jones ".
- I wrote "Marti": it takes some seconds but it founds and shows some records.
- I wrote "Martin Jo": it takes some seconds and tell me: "Too Many clauses". Here is the problem...if i restrict the search, why it gives me an Exception???
- I wrote "Martin Jon": it gives me results
the method used for the suggestion is the following(Note that i used a
MultiFieldQueryParser for the query.):
Code:
public List<Person> suggest(Object searchName) {
List<Person> result = null;
String input = (String)searchName;
MultiFieldQueryParser parser = new MultiFieldQueryParser(
new String[] { "firstName","lastName","taxCode" }, new StandardAnalyzer());
try {
input =addWc((String)searchName);
Query luceneQuery = parser.parse(input);
FullTextQuery ftq =
entityManager.createFullTextQuery(luceneQuery, Person.class);
result = ftq.getResultList();
}
catch(ParseException e){
e.printStackTrace();
return null;
}
return result
}
the method addWc is a custom method that adds wildcards element to the string:
eg:
input="Marti Jo"
output="Marti +Jo*"
AnyOne have ideas or solutions for me?