lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson" <erickerick...@gmail.com>
Subject Re: Phrase Search
Date Mon, 18 Jun 2007 13:43:33 GMT
Phrase queries won't help you here....

Your particular issue can be addressed, but I'm not sure it's a
reasonable long-term solution....

If you indexed your address field as UN_TOKENIZED, and
did NOT tokenize your query, it should give you what you want.
What's happening is that StandardAnalyzer is indexing indivdual
tokens, not phrases. So, doc 1 has the tokens
"hiran", "margi"

Doc 2 has tokens.
"hiran", "magri", "sec", and "10"

and so on...

Searching, even for phrases, on "hiran margi" matches
4 docs because those two tokens appear next to each other.

If, on the other hand, you index your address field UN_TOKENIZED,
then doc1 has a "token" of "hiran margi", while doc 2 has a token
of "hiran magri sec 10". Doc2 won't match a query on
"hiran margi" etc.

But, this may not be a good solution because searching on
"hiran" won't match *any* document. You might have to index
the same fields two different ways to get all the behavior you
want.

Best
Erick

On 6/18/07, Laxmilal Menaria <lmenaria@chambal.com> wrote:
>
> Hello everyone,
>
> I am lucene user and tried to implement pharse query, But now getting some
> logical problems in searching..
>
> My index have 4 fields: Name, Address &  City  and 6 docs.
> i.e  1. "Laxmilal Menaria", "Hiran Magri", "Udaipur",
>      2.  "Mohan Sharma", "Hiran Magri Sec 10", "Udaipur"
>      3.  "Rohit Bhargav", "Suraj pole", "Udaipur"
>      4.  "Laxmilal", "Hiran Magri Sec 4", "Ahemdabad"
>      5.  "Chandresh" , "Bihar", "Patna"
>      6.  "James", "Hiran Magri 18", "Delhi"
>
> Now search Address:"Hiran Magri" and got 4 results, But  I want 1 result
> only(Document-1), so what should I do ?
>
> My Search code is :
>                     sQuery="Hiran Magri"
>                     .
>                     .
>                      Dim lucQuery As Lucene.Net.Search.Query  = New
> Lucene.Net.QueryParsers.QueryParser("Address", New
> Lucene.Net.Analysis.Standard.StandardAnalyzer).Parse(sQuery)
>                     Dim lucHits As Lucene.Net.Search.Hits =
> lucIndexSearcher.Search(lucQuery)
>                     Dim intHitCount As Integer = lucHits.Length
>
>
> --
> Thanks,
> Laxmilal menaria
>
> http://www.minalyzer.com/
> http://www.chambal.com/
>

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