lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rajiv Roopan" <rajiv.roo...@gmail.com>
Subject Re: Search matching
Date Tue, 01 Aug 2006 17:19:24 GMT
Ok, this is how I'm indexing. Both in indexing and searching I'm using
SimpleAnalyzer()

String loc = "New York, NY";
doc.add(new Field("location", loc, Field.Store.NO, Field.Index.TOKENIZED));

String loc2 = "New York Mills, NY";
 doc.add(new Field("location", loc2, Field.Store.NO, Field.Index.TOKENIZED
));


and this is how I'm searching...

  String searchStr = "New York, NY";
            Analyzer analyzer = new SimpleAnalyzer();
            QueryParser parser = new QueryParser("location", analyzer);
            parser.setDefaultOperator(QueryParser.AND_OPERATOR);
            Query query = parser.parse( searchStr );

           Hits hits = searcher.search( query );

I've tried all query types and everytime "new york mills, ny" is in hits(0).
Both results have a score of 1.0. I know I can add some kind of sort to
always make the shorter field first. But shouldn't the first by default, due
to the scoring algorithm, be "new york, ny" because it's a shorter field?

let me know if i'm missing something. thanks!

rajiv

On 8/1/06, Simon Willnauer <simon.willnauer@googlemail.com> wrote:
>
> I guess so, but without any information about your code nobody can tell
> what.
> If you provide more information you willl get help!!
>
> regards simon
>
> On 8/1/06, Rajiv Roopan <rajiv.roopan@gmail.com> wrote:
> > Hello, I have an index of locations for example. I'm indexing one field
> > using SimpleAnalyzer.
> >
> > doc1: albany ny
> > doc2: hudson ny
> > doc3: new york ny
> > doc4: new york mills ny
> >
> > when I search for "new york ny" , the first result returned is always
> "new
> > york mills ny". Am I doing something incorrect?
> >
> > thanks in advance,
> > rajiv
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message