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 Karthik N S <ka...@controlnet.co.in> on 2005/07/18 14:12:28 UTC

BOOLEAN OPERATOR HOWTO


Hi

Lucene

Apologies......................

I have 2 Questions.

1) The Search Criteria  src  requires to automatically fill   "  "  between
Search words with a Boolean Operator   "  AND ".


2) The Search Criteria  src  requires to automatically recognise the
existing  Boolean Query  ' AND , + '  present and append the same
     with  out any manupulations.

Ex : -
Search Word  =

'Lucene in Action Erik hatcher and  Otis  + Gospodnetic '   =   lucene AND
action AND Eric  AND hatcher AND otis + gospodnetic .


How to Achieve this , Is there any mechanism built into Lucene to handle
such situations.



Thx in Advance.


WITH WARM REGARDS
HAVE A NICE DAY
[ N.S.KARTHIK]


Re: BOOLEAN OPERATOR HOWTO

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jul 21, 2005, at 5:09 AM, Karthik N S wrote:
>>> Do you want term  frequency across an individual document or the  
>>> entire
>>>
> index?
>
> Of course the Frequency will have to be across the entire index.
>
> In such case How does Explanation be usefull (Since Explanation is per
> document)

Explanation would not be useful for index level frequencies.  The  
only idea I have at the moment is for you to extract all the terms  
from the Query and individually find the frequency from IndexReader  
API.  I don't know of any other ways.

     Erik


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


RE: BOOLEAN OPERATOR HOWTO

Posted by Karthik N S <ka...@controlnet.co.in>.
Hi

Erik


Apologies......



>> Do you want term  frequency across an individual document or the entire
index?

Of course the Frequency will have to be across the entire index.

In such case How does Explanation be usefull (Since Explanation is per
document)


Thx in advance
Karthik



-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
Sent: Thursday, July 21, 2005 2:28 AM
To: java-user@lucene.apache.org
Subject: Re: BOOLEAN OPERATOR HOWTO



On Jul 19, 2005, at 8:31 AM, Karthik N S wrote:
> Given a Search word = 'erik OR hatcher AND otis OR gospodnetic' ,
> Is it
> possible to RETURN COUNT
> occurances for each of the word with in the Searched documents.
>
>
> This would give me the Each word's Term Frequency.
>
>
> How to achieve this

Wow - I really missed my guess on your question! :)

It is possible, but not directly (though you could spelunk the
Explanation to get this information per document).  Do you want term
frequency across an individual document or the entire index?

     Erik


>
> Thx in advance
> karthik
>
>
>
>
> -----Original Message-----
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
> Sent: Monday, July 18, 2005 6:39 PM
> To: java-user@lucene.apache.org
> Subject: Re: BOOLEAN OPERATOR HOWTO
>
>
>
> On Jul 18, 2005, at 8:12 AM, Karthik N S wrote:
>
>> I have 2 Questions.
>>
> But there were no question marks!   I don't understand your questions
> at all, sorry, but I'll see if I can decipher it somewhat....
>
>
>> 1) The Search Criteria  src  requires to automatically fill   "  "
>> between  Search words with a Boolean Operator   "  AND ".
>>
>
> You mean to achieve AND'd clauses?   By default, OR is the operator,
> and AND must be explicit.  You can construct a QueryParser instance
> and set the default operator to AND, though, and then OR must be
> explicit.
>
>
>>  2) The Search Criteria  src  requires to automatically recognise
>> the existing  Boolean Query  ' AND , + '  present and append the same
>>      with  out any manupulations.
>>
>> Ex : -
>> Search Word  =
>>
>> 'Lucene in Action Erik hatcher and  Otis  + Gospodnetic '   =
>> lucene AND action AND Eric  AND hatcher AND otis + gospodnetic .
>>
>>
>> How to Achieve this , Is there any mechanism built into Lucene to
>> handle such situations.
>>
>
> Yes, this sounds like the default operator is what you're looking
> for.  Since you use "Lucene in Action" as an example, flip to page 94
> for more discussion on this, and then flip to the other pages
> mentioned here:
>
>      http://www.lucenebook.com/search?query=default+operator
>
> Erik
>
>
> ---------------------------------------------------------------------
> 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


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


Re: BOOLEAN OPERATOR HOWTO

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jul 19, 2005, at 8:31 AM, Karthik N S wrote:
> Given a Search word = 'erik OR hatcher AND otis OR gospodnetic' ,  
> Is it
> possible to RETURN COUNT
> occurances for each of the word with in the Searched documents.
>
>
> This would give me the Each word's Term Frequency.
>
>
> How to achieve this

Wow - I really missed my guess on your question! :)

It is possible, but not directly (though you could spelunk the  
Explanation to get this information per document).  Do you want term  
frequency across an individual document or the entire index?

     Erik


>
> Thx in advance
> karthik
>
>
>
>
> -----Original Message-----
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
> Sent: Monday, July 18, 2005 6:39 PM
> To: java-user@lucene.apache.org
> Subject: Re: BOOLEAN OPERATOR HOWTO
>
>
>
> On Jul 18, 2005, at 8:12 AM, Karthik N S wrote:
>
>> I have 2 Questions.
>>
> But there were no question marks!   I don't understand your questions
> at all, sorry, but I'll see if I can decipher it somewhat....
>
>
>> 1) The Search Criteria  src  requires to automatically fill   "  "
>> between  Search words with a Boolean Operator   "  AND ".
>>
>
> You mean to achieve AND'd clauses?   By default, OR is the operator,
> and AND must be explicit.  You can construct a QueryParser instance
> and set the default operator to AND, though, and then OR must be
> explicit.
>
>
>>  2) The Search Criteria  src  requires to automatically recognise
>> the existing  Boolean Query  ' AND , + '  present and append the same
>>      with  out any manupulations.
>>
>> Ex : -
>> Search Word  =
>>
>> 'Lucene in Action Erik hatcher and  Otis  + Gospodnetic '   =
>> lucene AND action AND Eric  AND hatcher AND otis + gospodnetic .
>>
>>
>> How to Achieve this , Is there any mechanism built into Lucene to
>> handle such situations.
>>
>
> Yes, this sounds like the default operator is what you're looking
> for.  Since you use "Lucene in Action" as an example, flip to page 94
> for more discussion on this, and then flip to the other pages
> mentioned here:
>
>      http://www.lucenebook.com/search?query=default+operator
>
> Erik
>
>
> ---------------------------------------------------------------------
> 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: BOOLEAN OPERATOR HOWTO

Posted by Karthik N S <ka...@controlnet.co.in>.
Hi

Apologies.......

Given a Search word = 'erik OR hatcher AND otis OR gospodnetic' , Is it
possible to RETURN COUNT
occurances for each of the word with in the Searched documents.


This would give me the Each word's Term Frequency.


How to achieve this

Thx in advance
karthik




-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
Sent: Monday, July 18, 2005 6:39 PM
To: java-user@lucene.apache.org
Subject: Re: BOOLEAN OPERATOR HOWTO



On Jul 18, 2005, at 8:12 AM, Karthik N S wrote:
> I have 2 Questions.
But there were no question marks!   I don't understand your questions
at all, sorry, but I'll see if I can decipher it somewhat....

> 1) The Search Criteria  src  requires to automatically fill   "  "
> between  Search words with a Boolean Operator   "  AND ".

You mean to achieve AND'd clauses?   By default, OR is the operator,
and AND must be explicit.  You can construct a QueryParser instance
and set the default operator to AND, though, and then OR must be
explicit.

>  2) The Search Criteria  src  requires to automatically recognise
> the existing  Boolean Query  ' AND , + '  present and append the same
>      with  out any manupulations.
>
> Ex : -
> Search Word  =
>
> 'Lucene in Action Erik hatcher and  Otis  + Gospodnetic '   =
> lucene AND action AND Eric  AND hatcher AND otis + gospodnetic .
>
>
> How to Achieve this , Is there any mechanism built into Lucene to
> handle such situations.

Yes, this sounds like the default operator is what you're looking
for.  Since you use "Lucene in Action" as an example, flip to page 94
for more discussion on this, and then flip to the other pages
mentioned here:

     http://www.lucenebook.com/search?query=default+operator

Erik


---------------------------------------------------------------------
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: BOOLEAN OPERATOR HOWTO

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jul 18, 2005, at 8:12 AM, Karthik N S wrote:
> I have 2 Questions.
But there were no question marks!   I don't understand your questions  
at all, sorry, but I'll see if I can decipher it somewhat....

> 1) The Search Criteria  src  requires to automatically fill   "  "   
> between  Search words with a Boolean Operator   "  AND ".

You mean to achieve AND'd clauses?   By default, OR is the operator,  
and AND must be explicit.  You can construct a QueryParser instance  
and set the default operator to AND, though, and then OR must be  
explicit.

>  2) The Search Criteria  src  requires to automatically recognise  
> the existing  Boolean Query  ' AND , + '  present and append the same
>      with  out any manupulations.
>
> Ex : -
> Search Word  =
>
> 'Lucene in Action Erik hatcher and  Otis  + Gospodnetic '   =    
> lucene AND action AND Eric  AND hatcher AND otis + gospodnetic .
>
>
> How to Achieve this , Is there any mechanism built into Lucene to  
> handle such situations.

Yes, this sounds like the default operator is what you're looking  
for.  Since you use "Lucene in Action" as an example, flip to page 94  
for more discussion on this, and then flip to the other pages  
mentioned here:

     http://www.lucenebook.com/search?query=default+operator

Erik


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


Re: BOOLEAN OPERATOR HOWTO

Posted by Nader Henein <ns...@bayt.net>.
Sounds like straight forward string manipulation, just (a) tokenize your string into a collection, and then (b) manipulate the collection to reach your desired stream, then (c) join it back into a string. Oh and once again Erik is spelled consistently with a 'k' not a 'c', you got the first one right then, everything went to hell :-)

Nader



Karthik N S wrote:

> ** 
>
> *Hi*
>
> *Lucene*
>
> *Apologies......................*
>
> *I have 2 Questions.*
>
> *1) **The Search Criteria  src  requires to automatically fill   "  "  
> between  Search words with a Boolean Operator   "  AND ".*
>
> ** 
> *2)* **The Search Criteria  src  requires to automatically recognise 
> the existing  Boolean Query  ' AND , + '  present and append the same **
> **     with **** out any manupulations.**
> *
> ** 
> *Ex : - *
> *Search Word  =   *
> ** 
> *'Lucene in Action Erik hatcher and  Otis  + Gospodnetic '   =   
> **lucene AND action AND Eric  AND hatcher AND otis + gospodnetic .*
> *
>
> ** 
>
> *How to Achieve this , Is there any mechanism built into Lucene to 
> handle such situations.*
>
>  
>
> *Thx in Advance.*
>
>
> *WITH WARM REGARDS
> HAVE A NICE DAY
> [ N.S.KARTHIK]*
>

-- 

Nader S. Henein
Senior Applications Architect

Bayt.com


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