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 Rob Young <bu...@gmail.com> on 2005/10/25 13:00:23 UTC

Using analyzers with term queries

Hi,

I am using TermQuery s (and FuzzyQuery s) on the searching side and I 
would like to keep doing so. However, I would like to use the 
MetaphoneReplacementAnalyzer (from Lucene in Action) when indexing. How 
can I allow for this in searching if I'm using TermQuery?

Thanks
Rob

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


Re: Using analyzers with term queries

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On 25 Oct 2005, at 09:46, Jeff Rodenburg wrote:
> I don't mean to take the thread off-topic, but is this the recommended
> approach for any of the Query objects, i.e. SpanQuery or PhraseQuery?

In several applications I've built, a Query object is built via the  
API using an Analyzer directly and not using QueryParser.  So I  
believe the answer to your question is yes.  Currently QueryParser  
does not support the SpanQuery family, so you'd need to do this via  
the API or clever overriding of QueryParser methods in a subclass, or  
creating your own parser.

How you create a Query is really dependent on the application - so  
it's hard to say it's "recommended" to do it any particular way though.

     Erik



>
>
> On 10/25/05, Erik Hatcher <er...@ehatchersolutions.com> wrote:
>
>>
>>
>> On 25 Oct 2005, at 07:00, Rob Young wrote:
>>
>>> I am using TermQuery s (and FuzzyQuery s) on the searching side and
>>> I would like to keep doing so. However, I would like to use the
>>> MetaphoneReplacementAnalyzer (from Lucene in Action) when indexing.
>>> How can I allow for this in searching if I'm using TermQuery?
>>>
>>
>> You could simply call the metaphone .encode method on the text before
>> constructing a Term for TermQuery. Or, alternatively, you could run
>> the Analyzer on the String (using a StringReader) and capture the
>> token(s) that come back to formulate the TermQuery(s).
>>
>> 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: Using analyzers with term queries

Posted by Jeff Rodenburg <je...@gmail.com>.
I don't mean to take the thread off-topic, but is this the recommended
approach for any of the Query objects, i.e. SpanQuery or PhraseQuery?


On 10/25/05, Erik Hatcher <er...@ehatchersolutions.com> wrote:
>
>
> On 25 Oct 2005, at 07:00, Rob Young wrote:
> > I am using TermQuery s (and FuzzyQuery s) on the searching side and
> > I would like to keep doing so. However, I would like to use the
> > MetaphoneReplacementAnalyzer (from Lucene in Action) when indexing.
> > How can I allow for this in searching if I'm using TermQuery?
>
> You could simply call the metaphone .encode method on the text before
> constructing a Term for TermQuery. Or, alternatively, you could run
> the Analyzer on the String (using a StringReader) and capture the
> token(s) that come back to formulate the TermQuery(s).
>
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Using analyzers with term queries

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On 25 Oct 2005, at 07:00, Rob Young wrote:
> I am using TermQuery s (and FuzzyQuery s) on the searching side and  
> I would like to keep doing so. However, I would like to use the  
> MetaphoneReplacementAnalyzer (from Lucene in Action) when indexing.  
> How can I allow for this in searching if I'm using TermQuery?

You could simply call the metaphone .encode method on the text before  
constructing a Term for TermQuery.  Or, alternatively, you could run  
the Analyzer on the String (using a StringReader) and capture the  
token(s) that come back to formulate the TermQuery(s).

     Erik


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