-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Searching good, but...
PostPosted: Wed Dec 02, 2009 6:39 am 
Newbie

Joined: Tue Nov 17, 2009 12:35 pm
Posts: 5
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?


Top
 Profile  
 
 Post subject: Re: Searching good, but...
PostPosted: Wed Dec 02, 2009 7:14 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
http://wiki.apache.org/lucene-java/Luce ... ception.3F


Top
 Profile  
 
 Post subject: Re: Searching good, but...
PostPosted: Wed Dec 02, 2009 11:45 am 
Newbie

Joined: Tue Nov 17, 2009 12:35 pm
Posts: 5
hardy.ferentschik wrote:
http://wiki.apache.org/lucene-java/LuceneFAQ#Why_am_I_getting_a_TooManyClauses_exception.3F

Ok. I saw that wiki, but in my situation i'm not using a BooleanQuery...and i don't know how better make this method....i'm searching into 3 fields...is there an object more usefull than MultiFieldQueryParser?


Top
 Profile  
 
 Post subject: Re: Searching good, but...
PostPosted: Wed Dec 02, 2009 2:10 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

yes you do a boolean query :)

Quote:
The following types of queries are expanded by Lucene before it does the search: RangeQuery, PrefixQuery, WildcardQuery, FuzzyQuery. For example, if the indexed documents contain the terms "car" and "cars" the query "ca*" will be expanded to "car OR cars" before the search takes place.


In your original post you are saying that addWc() adds wildcard characters. And as the documentation says, wildcard searches are expanded to boolean queries. This means that Jo* will expand to something like:
Jo OR Jon OR Joe ... I guess in your case jo* leads to more than 1024 terms.

--Hardy


Top
 Profile  
 
 Post subject: Re: Searching good, but...
PostPosted: Fri Dec 04, 2009 5:28 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
We had the same problem with 2009*. Basically we just captured the exception and sent back a pleasent message to the user asking them to refine their queries. There was the option to change the 1024 settings but we decided to leave it as is. I might consider using the filter option as recommended.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.