Not getting desired result through TermQuery

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Not getting desired result through TermQuery

Ashish Parab
Hi Team,

I am new to Lucene and been exploring Lucene 7.4.0  for past few months.

please take a look at attached IndexFiles.java, in which I am indexing all the files present under specified folder. also for every document, a field namely ashish is stored.

now the indexing is ready, I am trying to search it via TermQuery api. code(SearchFiles_Mine.java) for the same is also attached.


My issue is when I use TermQuery I get 0 hit where as if same thing is tried via QueryParser api it gives 10 hit. 

why is this happening? will you explain the functionality TermQuery API, in the context of my code ?

regards,
Ashish Parab


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Not getting desired result through TermQuery

Michael Sokolov-4
It's impossible to tell for sure from the info you provided -- attachments
are not included in messages on this mailing list - but my guess is that
when you use the QueryParser api you are getting a query that has the
benefit of text processing using an Analyzer (lower-casing and other text
transformations are done by an Analyzer), but TermQuery just matches
exactly the term you give it, without any such processing.

On Mon, Jul 16, 2018 at 11:02 AM Ashish Parab <[hidden email]>
wrote:

> Hi Team,
>
> I am new to Lucene and been exploring Lucene 7.4.0  for past few months.
>
> please take a look at attached IndexFiles.java, in which I am indexing all
> the files present under specified folder. also for every document, a field
> namely ashish is stored.
>
> now the indexing is ready, I am trying to search it via TermQuery api.
> code(SearchFiles_Mine.java) for the same is also attached.
>
>
> My issue is when I use TermQuery I get 0 hit where as if same thing is
> tried via QueryParser api it gives 10 hit.
>
> why is this happening? will you explain the functionality TermQuery API,
> in the context of my code ?
>
> regards,
> Ashish Parab
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Not getting desired result through TermQuery

baris.kazar
My problem seems similar to this one.

i make sure index has all lower cased and TermQuery search term also
gets all lower cased.

i tokenize the search string since index uses standardtokenizer and
standardfilter and lowecasefilter and asciifoldingfilter.

My index uses standardtokenizer and the following due to my second query
requirements:

StandardFilter
LowerCaseFilter
ASCIIFoldingFilter
StopFilter


But given what i do for TermQuery as i listed above, it should still
find some hits, right?

My Booleanquery is built by the builder:

booleanQueryBuilder.add((Query)queryArr.get(k), BooleanClause.Occur.MUST);


Best regards


On 7/18/18 3:22 PM, Michael Sokolov wrote:

> It's impossible to tell for sure from the info you provided -- attachments
> are not included in messages on this mailing list - but my guess is that
> when you use the QueryParser api you are getting a query that has the
> benefit of text processing using an Analyzer (lower-casing and other text
> transformations are done by an Analyzer), but TermQuery just matches
> exactly the term you give it, without any such processing.
>
> On Mon, Jul 16, 2018 at 11:02 AM Ashish Parab <[hidden email]>
> wrote:
>
>> Hi Team,
>>
>> I am new to Lucene and been exploring Lucene 7.4.0  for past few months.
>>
>> please take a look at attached IndexFiles.java, in which I am indexing all
>> the files present under specified folder. also for every document, a field
>> namely ashish is stored.
>>
>> now the indexing is ready, I am trying to search it via TermQuery api.
>> code(SearchFiles_Mine.java) for the same is also attached.
>>
>>
>> My issue is when I use TermQuery I get 0 hit where as if same thing is
>> tried via QueryParser api it gives 10 hit.
>>
>> why is this happening? will you explain the functionality TermQuery API,
>> in the context of my code ?
>>
>> regards,
>> Ashish Parab
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]