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 "m.harig" <m....@gmail.com> on 2009/10/21 13:22:45 UTC

singular and plural search

hello all

        i've a doubt in plural & singular word searching , i've got code
snippet from nabble forum , 

private static Analyzer createEnglishAnalyzer() {
return new Analyzer() {
        public TokenStream tokenStream(String fieldName, Reader reader)
{
                TokenStream result = new StandardTokenizer(reader);
                result = new StandardFilter(result);
                result = new LowerCaseFilter(result);
                result = new StopFilter(result,
StandardAnalyzer.STOP_WORDS);
                result = new SnowballFilter(result, "English");
                return result;
        }
};
} 

to do my above , but when i search for a keyword "loans" , this code turns
my keyword to "loan" and gives me the results for "loan" keyword , but when
i search for "loan" it should return the results for "loans" keyword.

please anyone suggest me.
-- 
View this message in context: http://www.nabble.com/singular-and-plural-search-tp25990682p25990682.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: singular and plural search

Posted by Matthew Hall <mh...@informatics.jax.org>.
If I recall correctly the highlighter also has an analyzer passed to 
it.  Ensure that this is the same one as well.

Matt

m.harig wrote:
> Thanks erick ,
>
>     It works fine , if i use the (code snippet found from nabble) same
> analyzer for both indexing & querying .
>
> But the highlighter has gone for plural words. Hope i need to search more ,
> i'll come back to you once if i can't find out.  Thanks again erick.
>   



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


Re: singular and plural search

Posted by "m.harig" <m....@gmail.com>.
Thanks erick ,

    It works fine , if i use the (code snippet found from nabble) same
analyzer for both indexing & querying .

But the highlighter has gone for plural words. Hope i need to search more ,
i'll come back to you once if i can't find out.  Thanks again erick.
-- 
View this message in context: http://www.nabble.com/singular-and-plural-search-tp25990682p25992428.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: singular and plural search

Posted by "m.harig" <m....@gmail.com>.
thanks erick ,

A little more information would help here.1> Are you using the same analyzer
at both index and query time?

 no . sorry , am using StandardAnalyzer at the index time , during querying
am using the code snippet found from nabble.

2> Assuming <1> is "yes", did you re-index your data after you created this
analyzer?

no.

3> What are the results of query.toString()? Looking at that might help you
pinpoint what's going on.

am getting singular word for all field.

4> Have you examined your index using Luke to see if it has what you *think*
it should?

yes , i did it , it also returns the same

5> If all of the above doesn't do you any good, I've usually found that
writing a small, self-contained test case to illustrate the problem is a
great help. Usually, during the course of writing the test case I find the
problem. And it's usually in my code <G>. And if it's *not* in my code, a
test case provides the Lucene folks with something to work with.

sorry , am not clear with this.

The analyzer itself looks like it should do what you want on a cursory
inspection.....

Best
Erick

-- 
View this message in context: http://www.nabble.com/singular-and-plural-search-tp25990682p25992140.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: singular and plural search

Posted by Erick Erickson <er...@gmail.com>.
A little more information would help here.1> Are you using the same analyzer
at both index and query time?
2> Assuming <1> is "yes", did you re-index your data after you created this
analyzer?
3> What are the results of query.toString()? Looking at that might help you
pinpoint what's going on.
4> Have you examined your index using Luke to see if it has what you *think*
it should?
5> If all of the above doesn't do you any good, I've usually found that
writing a small, self-contained test case to illustrate the problem is a
great help. Usually, during the course of writing the test case I find the
problem. And it's usually in my code <G>. And if it's *not* in my code, a
test case provides the Lucene folks with something to work with.

The analyzer itself looks like it should do what you want on a cursory
inspection.....

Best
Erick

On Wed, Oct 21, 2009 at 7:22 AM, m.harig <m....@gmail.com> wrote:

>
> hello all
>
>        i've a doubt in plural & singular word searching , i've got code
> snippet from nabble forum ,
>
> private static Analyzer createEnglishAnalyzer() {
> return new Analyzer() {
>        public TokenStream tokenStream(String fieldName, Reader reader)
> {
>                TokenStream result = new StandardTokenizer(reader);
>                result = new StandardFilter(result);
>                result = new LowerCaseFilter(result);
>                result = new StopFilter(result,
> StandardAnalyzer.STOP_WORDS);
>                result = new SnowballFilter(result, "English");
>                return result;
>        }
> };
> }
>
> to do my above , but when i search for a keyword "loans" , this code turns
> my keyword to "loan" and gives me the results for "loan" keyword , but when
> i search for "loan" it should return the results for "loans" keyword.
>
> please anyone suggest me.
> --
> View this message in context:
> http://www.nabble.com/singular-and-plural-search-tp25990682p25990682.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
>
>