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 Mufaddal Khumri <mk...@allegromedical.com> on 2006/02/16 20:41:41 UTC

Strange Problem ... Luke returns results Lucene api does not.

Hi,

I have a query that gets hits via luke. I can see the documents it 
finds. But when I run the same query via my java code it returns 0 hits.

Note:
1. I am using standard analyzer while indexing and searching.
2. I have made sure that I am querying the same index via luke or 
through my java program.

This is the call I make in my java code.
        BooleanQuery finalQuery = new BooleanQuery();
        .....
        .....
        log.debug(finalQuery.toString());

        hits = 
IndexSearcherManager.getIndexSearcher(indexPath).search(finalQuery);    
       

        log.debug("Hits length = " + hits.length());

The output of the first log statement above is:

+(+contentNew:Wireless +contentNew:fm +contentNew:car 
+contentNew:transmitter) +entity:category +(name:Wireless fm car 
transmitter^40.0 ((name:Wireless name:fm name:car 
name:transmitter)^10.0) contentNew:Wireless fm car transmitter^20.0 
(contentNew:Wireless contentNew:fm contentNew:car contentNew:transmitter))

The output of the second log statement above is:

Hits length = 0

I run the above query against the same index via Luke and I get search 
results that I expected.

Any ideas as to why my java call does not return any hits? how i might 
be able to debug this?

Thanks,


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


Re: Strange Problem ... Luke returns results Lucene api does not.

Posted by Mufaddal Khumri <mk...@allegromedical.com>.
Yes. thats exactly the problem. I just found out that analyzer was not 
being set correctly.

Thanks,

Chris Hostetter wrote:

>: Standard analyzer lower cases while indexing and searching.
>
>Correct, but since the toString() of your query still has capital words in
>it (like "contentNew:Wireless") you obviously didn't build this query
>using the StandardAnalyzer -- IndexSearcher doesn't apply any Analyzers
>for you when you search -- it's the responsability of whatever is
>constructing your query (be that custom code you've written, or
>QueryParser) to run the input thoguh the appropraite Analyzer.
>
>when you paste that query into Luke, it *does* run it through the
>QueryParser for you -- so the text gets analyzed and lower cased.
>
>
>
>:
>: The BooleanQuery, finalQuery.toString() in my case below is:
>:
>: +(+contentNew:wireless +contentNew:fm +contentNew:car
>: +contentNew:transmitter) +entity:product +(name:wireless fm car
>: transmitter^40.0 ((name:wireless name:fm name:car
>: name:transmitter)^10.0) contentNew:wireless fm car transmitter^20.0
>: (contentNew:wireless contentNew:fm contentNew:car contentNew:transmitter))
>:
>: OR
>:
>: +(+contentNew:Wireless +contentNew:fm +contentNew:car
>: +contentNew:transmitter) +entity:category +(name:Wireless fm car
>: transmitter^40.0 ((name:Wireless name:fm name:car name:transmitter)
>: ^10.0) contentNew:Wireless fm car transmitter^20.0  (contentNew:Wireless
>: contentNew:fm contentNew:car  contentNew:transmitter))
>:
>: work in Luke just fine. I am using the StandardAnalyzer in Luke.
>:
>: But when i try to execute the above boolean query via a call to
>: IndexSearcher.search(finalQuery) it returns no hits.
>:
>: Erik Hatcher wrote:
>:
>: > How are you constructing your BooleanQuery and what Analyzer are you
>: > using with Luke?   You have some capitalized words in your query, and
>: > most analyzers would lowercase those, which may be the issue (perhaps
>: > you indexed the capitalized words?).
>: >
>: >     Erik
>: >
>: > On Feb 16, 2006, at 2:41 PM, Mufaddal Khumri wrote:
>: >
>: >> Hi,
>: >>
>: >> I have a query that gets hits via luke. I can see the documents it
>: >> finds. But when I run the same query via my java code it returns 0
>: >> hits.
>: >>
>: >> Note:
>: >> 1. I am using standard analyzer while indexing and searching.
>: >> 2. I have made sure that I am querying the same index via luke or
>: >> through my java program.
>: >>
>: >> This is the call I make in my java code.
>: >>        BooleanQuery finalQuery = new BooleanQuery();
>: >>        .....
>: >>        .....
>: >>        log.debug(finalQuery.toString());
>: >>
>: >>        hits = IndexSearcherManager.getIndexSearcher
>: >> (indexPath).search(finalQuery);
>: >>        log.debug("Hits length = " + hits.length());
>: >>
>: >> The output of the first log statement above is:
>: >>
>: >> +(+contentNew:Wireless +contentNew:fm +contentNew:car
>: >> +contentNew:transmitter) +entity:category +(name:Wireless fm car
>: >> transmitter^40.0 ((name:Wireless name:fm name:car name:transmitter)
>: >> ^10.0) contentNew:Wireless fm car transmitter^20.0
>: >> (contentNew:Wireless contentNew:fm contentNew:car
>: >> contentNew:transmitter))
>: >>
>: >> The output of the second log statement above is:
>: >>
>: >> Hits length = 0
>: >>
>: >> I run the above query against the same index via Luke and I get
>: >> search results that I expected.
>: >>
>: >> Any ideas as to why my java call does not return any hits? how i
>: >> might be able to debug this?
>: >>
>: >> Thanks,
>: >>
>: >>
>: >> ---------------------------------------------------------------------
>: >> 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
>: >
>:
>:
>: ---------------------------------------------------------------------
>: To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>: For additional commands, e-mail: java-user-help@lucene.apache.org
>:
>
>
>
>-Hoss
>
>
>---------------------------------------------------------------------
>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: Strange Problem ... Luke returns results Lucene api does not.

Posted by Chris Hostetter <ho...@fucit.org>.
: Standard analyzer lower cases while indexing and searching.

Correct, but since the toString() of your query still has capital words in
it (like "contentNew:Wireless") you obviously didn't build this query
using the StandardAnalyzer -- IndexSearcher doesn't apply any Analyzers
for you when you search -- it's the responsability of whatever is
constructing your query (be that custom code you've written, or
QueryParser) to run the input thoguh the appropraite Analyzer.

when you paste that query into Luke, it *does* run it through the
QueryParser for you -- so the text gets analyzed and lower cased.



:
: The BooleanQuery, finalQuery.toString() in my case below is:
:
: +(+contentNew:wireless +contentNew:fm +contentNew:car
: +contentNew:transmitter) +entity:product +(name:wireless fm car
: transmitter^40.0 ((name:wireless name:fm name:car
: name:transmitter)^10.0) contentNew:wireless fm car transmitter^20.0
: (contentNew:wireless contentNew:fm contentNew:car contentNew:transmitter))
:
: OR
:
: +(+contentNew:Wireless +contentNew:fm +contentNew:car
: +contentNew:transmitter) +entity:category +(name:Wireless fm car
: transmitter^40.0 ((name:Wireless name:fm name:car name:transmitter)
: ^10.0) contentNew:Wireless fm car transmitter^20.0  (contentNew:Wireless
: contentNew:fm contentNew:car  contentNew:transmitter))
:
: work in Luke just fine. I am using the StandardAnalyzer in Luke.
:
: But when i try to execute the above boolean query via a call to
: IndexSearcher.search(finalQuery) it returns no hits.
:
: Erik Hatcher wrote:
:
: > How are you constructing your BooleanQuery and what Analyzer are you
: > using with Luke?   You have some capitalized words in your query, and
: > most analyzers would lowercase those, which may be the issue (perhaps
: > you indexed the capitalized words?).
: >
: >     Erik
: >
: > On Feb 16, 2006, at 2:41 PM, Mufaddal Khumri wrote:
: >
: >> Hi,
: >>
: >> I have a query that gets hits via luke. I can see the documents it
: >> finds. But when I run the same query via my java code it returns 0
: >> hits.
: >>
: >> Note:
: >> 1. I am using standard analyzer while indexing and searching.
: >> 2. I have made sure that I am querying the same index via luke or
: >> through my java program.
: >>
: >> This is the call I make in my java code.
: >>        BooleanQuery finalQuery = new BooleanQuery();
: >>        .....
: >>        .....
: >>        log.debug(finalQuery.toString());
: >>
: >>        hits = IndexSearcherManager.getIndexSearcher
: >> (indexPath).search(finalQuery);
: >>        log.debug("Hits length = " + hits.length());
: >>
: >> The output of the first log statement above is:
: >>
: >> +(+contentNew:Wireless +contentNew:fm +contentNew:car
: >> +contentNew:transmitter) +entity:category +(name:Wireless fm car
: >> transmitter^40.0 ((name:Wireless name:fm name:car name:transmitter)
: >> ^10.0) contentNew:Wireless fm car transmitter^20.0
: >> (contentNew:Wireless contentNew:fm contentNew:car
: >> contentNew:transmitter))
: >>
: >> The output of the second log statement above is:
: >>
: >> Hits length = 0
: >>
: >> I run the above query against the same index via Luke and I get
: >> search results that I expected.
: >>
: >> Any ideas as to why my java call does not return any hits? how i
: >> might be able to debug this?
: >>
: >> Thanks,
: >>
: >>
: >> ---------------------------------------------------------------------
: >> 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
: >
:
:
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
: For additional commands, e-mail: java-user-help@lucene.apache.org
:



-Hoss


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


Re: Strange Problem ... Luke returns results Lucene api does not.

Posted by Mufaddal Khumri <mk...@allegromedical.com>.
I am using the standard analyzer with luke.

Standard analyzer lower cases while indexing and searching.

The BooleanQuery, finalQuery.toString() in my case below is:

+(+contentNew:wireless +contentNew:fm +contentNew:car 
+contentNew:transmitter) +entity:product +(name:wireless fm car 
transmitter^40.0 ((name:wireless name:fm name:car 
name:transmitter)^10.0) contentNew:wireless fm car transmitter^20.0 
(contentNew:wireless contentNew:fm contentNew:car contentNew:transmitter))

OR

+(+contentNew:Wireless +contentNew:fm +contentNew:car  
+contentNew:transmitter) +entity:category +(name:Wireless fm car  
transmitter^40.0 ((name:Wireless name:fm name:car name:transmitter) 
^10.0) contentNew:Wireless fm car transmitter^20.0  (contentNew:Wireless 
contentNew:fm contentNew:car  contentNew:transmitter))

work in Luke just fine. I am using the StandardAnalyzer in Luke.

But when i try to execute the above boolean query via a call to 
IndexSearcher.search(finalQuery) it returns no hits.

Erik Hatcher wrote:

> How are you constructing your BooleanQuery and what Analyzer are you  
> using with Luke?   You have some capitalized words in your query, and  
> most analyzers would lowercase those, which may be the issue (perhaps  
> you indexed the capitalized words?).
>
>     Erik
>
> On Feb 16, 2006, at 2:41 PM, Mufaddal Khumri wrote:
>
>> Hi,
>>
>> I have a query that gets hits via luke. I can see the documents it  
>> finds. But when I run the same query via my java code it returns 0  
>> hits.
>>
>> Note:
>> 1. I am using standard analyzer while indexing and searching.
>> 2. I have made sure that I am querying the same index via luke or  
>> through my java program.
>>
>> This is the call I make in my java code.
>>        BooleanQuery finalQuery = new BooleanQuery();
>>        .....
>>        .....
>>        log.debug(finalQuery.toString());
>>
>>        hits = IndexSearcherManager.getIndexSearcher 
>> (indexPath).search(finalQuery);
>>        log.debug("Hits length = " + hits.length());
>>
>> The output of the first log statement above is:
>>
>> +(+contentNew:Wireless +contentNew:fm +contentNew:car  
>> +contentNew:transmitter) +entity:category +(name:Wireless fm car  
>> transmitter^40.0 ((name:Wireless name:fm name:car name:transmitter) 
>> ^10.0) contentNew:Wireless fm car transmitter^20.0  
>> (contentNew:Wireless contentNew:fm contentNew:car  
>> contentNew:transmitter))
>>
>> The output of the second log statement above is:
>>
>> Hits length = 0
>>
>> I run the above query against the same index via Luke and I get  
>> search results that I expected.
>>
>> Any ideas as to why my java call does not return any hits? how i  
>> might be able to debug this?
>>
>> Thanks,
>>
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: Strange Problem ... Luke returns results Lucene api does not.

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
How are you constructing your BooleanQuery and what Analyzer are you  
using with Luke?   You have some capitalized words in your query, and  
most analyzers would lowercase those, which may be the issue (perhaps  
you indexed the capitalized words?).

	Erik

On Feb 16, 2006, at 2:41 PM, Mufaddal Khumri wrote:

> Hi,
>
> I have a query that gets hits via luke. I can see the documents it  
> finds. But when I run the same query via my java code it returns 0  
> hits.
>
> Note:
> 1. I am using standard analyzer while indexing and searching.
> 2. I have made sure that I am querying the same index via luke or  
> through my java program.
>
> This is the call I make in my java code.
>        BooleanQuery finalQuery = new BooleanQuery();
>        .....
>        .....
>        log.debug(finalQuery.toString());
>
>        hits = IndexSearcherManager.getIndexSearcher 
> (indexPath).search(finalQuery);
>        log.debug("Hits length = " + hits.length());
>
> The output of the first log statement above is:
>
> +(+contentNew:Wireless +contentNew:fm +contentNew:car  
> +contentNew:transmitter) +entity:category +(name:Wireless fm car  
> transmitter^40.0 ((name:Wireless name:fm name:car name:transmitter) 
> ^10.0) contentNew:Wireless fm car transmitter^20.0  
> (contentNew:Wireless contentNew:fm contentNew:car  
> contentNew:transmitter))
>
> The output of the second log statement above is:
>
> Hits length = 0
>
> I run the above query against the same index via Luke and I get  
> search results that I expected.
>
> Any ideas as to why my java call does not return any hits? how i  
> might be able to debug this?
>
> Thanks,
>
>
> ---------------------------------------------------------------------
> 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