You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Joe K <ch...@gmail.com> on 2008/04/10 14:53:06 UTC

WildCardQuery and TooManyClauses

Hello everybody,
I know there was written a tons of words about this issue, but I'm just not
clear enough about it.

I have these facts:

1. my query is always 1 letter and *, eg. M*
2. i always want to get max 200 results, no more!
3. i don't want to fix this issue by setting maxClauseCount

I just don't see the easy way how to get my results, did i missed something?

>From what I've read here I know that probably i should play with filters or
with WildCardEnum, but why?
I just want to get simple this:
SELECT FROM XXX WHERE XXX.name LIKE 'M%' LIMIT 200;

(there is no filtering in this query except the wildcard itself)

Please, what is the easiest solution to achieve this?

Thanks in advance,
Chose

Re: about NullPointerException in DocumentsWriter$ThreadState.init(DocumentsWriter.java:751)

Posted by Michael McCandless <lu...@mikemccandless.com>.
I think this is something you just shouldn't do?

Ie, if you call Document.addField(null), it is silently accepted and  
then causes that exception when added the document, but my feeling is  
you shouldn't do that.

Mike

kai.hu wrote:
>
> i got a problem yesterday,
> java.lang.NullPointerException
> at org.apache.lucene.index.DocumentsWriter$ThreadState.init 
> (DocumentsWriter.java:751)
> at org.apache.lucene.index.DocumentsWriter.getThreadState 
> (DocumentsWriter.java:2391)
> at org.apache.lucene.index.DocumentsWriter.updateDocument 
> (DocumentsWriter.java:2434)
> at org.apache.lucene.index.DocumentsWriter.addDocument 
> (DocumentsWriter.java:2422)
> at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java: 
> 1445)
> at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java: 
> 1424)
>
> so i debug the code ,found if the document add a null Field,it will  
> throw this Exception.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


about NullPointerException in DocumentsWriter$ThreadState.init(DocumentsWriter.java:751)

Posted by "kai.hu" <li...@hotmail.com>.
 i got a problem yesterday,
 java.lang.NullPointerException
 at 
org.apache.lucene.index.DocumentsWriter$ThreadState.init(DocumentsWriter.java:751)
 at 
org.apache.lucene.index.DocumentsWriter.getThreadState(DocumentsWriter.java:2391)
 at 
org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:2434)
 at 
org.apache.lucene.index.DocumentsWriter.addDocument(DocumentsWriter.java:2422)
 at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1445)
 at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1424)

 so i debug the code ,found if the document add a null Field,it will throw 
this Exception. 


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: WildCardQuery and TooManyClauses

Posted by Konstantyn Smirnov <in...@yahoo.com>.


Konstantyn Smirnov wrote:
> 
> So, how can I plug the WildcardFilter in, to prevent TooManyClauses? Are
> there other ways, than using the trunk? 
> 

Now I ended up in overriding also QueryParser.getPrefixQuery() method, using
ConstantScoreQuery and PrefixFilter. MaxClauseCountExc is gone, but is it
the right way?
-- 
View this message in context: http://www.nabble.com/WildCardQuery-and-TooManyClauses-tp16610177p19570188.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: WildCardQuery and TooManyClauses

Posted by Konstantyn Smirnov <in...@yahoo.com>.


Michael McCandless-2 wrote:
> 
> 
> It's only with the trunk version of Lucene that QueryParser calls  
> getWildcardQuery on parsing a wildcard string from the user's query.
> 
I see..

So, how can I plug the WildcardFilter in, to prevent TooManyClauses? Are
there other ways, than using the trunk? 
-- 
View this message in context: http://www.nabble.com/WildCardQuery-and-TooManyClauses-tp16610177p19557943.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: WildCardQuery and TooManyClauses

Posted by Michael McCandless <lu...@mikemccandless.com>.
It's only with the trunk version of Lucene that QueryParser calls  
getWildcardQuery on parsing a wildcard string from the user's query.

Mike

Konstantyn Smirnov wrote:

>
>
>
> Beard, Brian wrote:
>>
>> 1) Extend QueryParser to override the getWildcardQuery method.
>>
>
> Kinda late :), but I still have another question:
>
> Who calls that getWildcardQuery() method?
>
> I subclassed the QueryParser, but that method does never get  
> invoked, even
> if the query contains *.
>
> Shall I override some other methods? Or shall I call the method  
> directly?
>
> Thanx
> -- 
> View this message in context: http://www.nabble.com/WildCardQuery-and-TooManyClauses-tp16610177p19555644.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: WildCardQuery and TooManyClauses

Posted by Konstantyn Smirnov <in...@yahoo.com>.


Beard, Brian wrote:
> 
> 1) Extend QueryParser to override the getWildcardQuery method.
> 

Kinda late :), but I still have another question:

Who calls that getWildcardQuery() method? 

I subclassed the QueryParser, but that method does never get invoked, even
if the query contains *.

Shall I override some other methods? Or shall I call the method directly?

Thanx
-- 
View this message in context: http://www.nabble.com/WildCardQuery-and-TooManyClauses-tp16610177p19555644.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: WildCardQuery and TooManyClauses

Posted by Joe K <ch...@gmail.com>.
Donna,
so this doesn't work because search calls internaly MultiTermQuery.rewrite
which causes TooManyClauses exception anyway even if the maxnumhits
is set to 200 !!

So I am lost again...

Chose


On Thu, Apr 10, 2008 at 3:02 PM, Donna L Gresh <gr...@us.ibm.com> wrote:

> Doesn't the following do what you want with maxnumhits =200?
>                TopDocs td;
>                td = indexSearcher.search(query, filter, maxnumhits);
> where filter can be null
>
>
>
> Donna L. Gresh
> Services Research, Mathematical Sciences Department
> IBM T.J. Watson Research Center
> (914) 945-2472
> http://www.research.ibm.com/people/g/donnagresh
> gresh@us.ibm.com
>
>
> "Joe K" <ch...@gmail.com> wrote on 04/10/2008 08:53:06 AM:
>
> > Hello everybody,
> > I know there was written a tons of words about this issue, but I'm just
> not
> > clear enough about it.
> >
> > I have these facts:
> >
> > 1. my query is always 1 letter and *, eg. M*
> > 2. i always want to get max 200 results, no more!
> > 3. i don't want to fix this issue by setting maxClauseCount
> >
> > I just don't see the easy way how to get my results, did i missed
> something?
> >
> > From what I've read here I know that probably i should play with filters
> or
> > with WildCardEnum, but why?
> > I just want to get simple this:
> > SELECT FROM XXX WHERE XXX.name LIKE 'M%' LIMIT 200;
> >
> > (there is no filtering in this query except the wildcard itself)
> >
> > Please, what is the easiest solution to achieve this?
> >
> > Thanks in advance,
> > Chose
>

Re: WildCardQuery and TooManyClauses

Posted by Joe K <ch...@gmail.com>.
Hi Donna,
thanks for the reply!

I didn't try yet, but you are probably right that this should work for me.
The filter parameter and the fact that TopDocs doesn't have the
getter to the scoreDocs were confusing to me.

Thanks a lot,
Chose


On Thu, Apr 10, 2008 at 3:02 PM, Donna L Gresh <gr...@us.ibm.com> wrote:

> Doesn't the following do what you want with maxnumhits =200?
>                TopDocs td;
>                td = indexSearcher.search(query, filter, maxnumhits);
> where filter can be null
>
>
>
> Donna L. Gresh
> Services Research, Mathematical Sciences Department
> IBM T.J. Watson Research Center
> (914) 945-2472
> http://www.research.ibm.com/people/g/donnagresh
> gresh@us.ibm.com
>
>
> "Joe K" <ch...@gmail.com> wrote on 04/10/2008 08:53:06 AM:
>
> > Hello everybody,
> > I know there was written a tons of words about this issue, but I'm just
> not
> > clear enough about it.
> >
> > I have these facts:
> >
> > 1. my query is always 1 letter and *, eg. M*
> > 2. i always want to get max 200 results, no more!
> > 3. i don't want to fix this issue by setting maxClauseCount
> >
> > I just don't see the easy way how to get my results, did i missed
> something?
> >
> > From what I've read here I know that probably i should play with filters
> or
> > with WildCardEnum, but why?
> > I just want to get simple this:
> > SELECT FROM XXX WHERE XXX.name LIKE 'M%' LIMIT 200;
> >
> > (there is no filtering in this query except the wildcard itself)
> >
> > Please, what is the easiest solution to achieve this?
> >
> > Thanks in advance,
> > Chose
>

Re: WildCardQuery and TooManyClauses

Posted by Donna L Gresh <gr...@us.ibm.com>.
Doesn't the following do what you want with maxnumhits =200?
                TopDocs td;
                td = indexSearcher.search(query, filter, maxnumhits);
where filter can be null



Donna L. Gresh
Services Research, Mathematical Sciences Department
IBM T.J. Watson Research Center
(914) 945-2472
http://www.research.ibm.com/people/g/donnagresh
gresh@us.ibm.com


"Joe K" <ch...@gmail.com> wrote on 04/10/2008 08:53:06 AM:

> Hello everybody,
> I know there was written a tons of words about this issue, but I'm just 
not
> clear enough about it.
> 
> I have these facts:
> 
> 1. my query is always 1 letter and *, eg. M*
> 2. i always want to get max 200 results, no more!
> 3. i don't want to fix this issue by setting maxClauseCount
> 
> I just don't see the easy way how to get my results, did i missed 
something?
> 
> From what I've read here I know that probably i should play with filters 
or
> with WildCardEnum, but why?
> I just want to get simple this:
> SELECT FROM XXX WHERE XXX.name LIKE 'M%' LIMIT 200;
> 
> (there is no filtering in this query except the wildcard itself)
> 
> Please, what is the easiest solution to achieve this?
> 
> Thanks in advance,
> Chose