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: Exact match on entire field
Date Wed, 06 May 2009 15:14:46 GMT
how much data are you talking about here? Could you use a KeywordAnalyzer
(perhaps in a duplicated field) with appropriate filtering (to lowercase,
remove
punctuation, etc)?

Best
Erick

On Wed, May 6, 2009 at 4:50 AM, Laura Hollink <laurah@cs.vu.nl> wrote:

> Hi,
>
> I am trying to distinguish between a document that matches the query
> because the query *appears* in one of the fields, and a document that
> matches the query because the query equals the complete field. I do want to
> use an Analyzer for case- and punctuation normalization. For example:
>
> The query "bloemendaal" matches the complete field "Bloemendaal" in a
> document in my result list.
> The query "adele" only partly matches the field "Adele Bloemendaal" in
> another document.
>
> What is the best way to do this?
> I currently solve it by first searching in a normal way, and than using the
> QueryParser on both the query and the relevant field in the documents in my
> result list. Finally, I simply compare the parsed query and the parsed
> field.
>
>        QueryParser parser = new QueryParser(field,new StandardAnalyzer());
>        Query query = parser.parse(q);
>        Hits hits = is.search(query);
>        ...
>        Document doc = hits.doc(i);
>        Query myfield = parser.parse(doc.get("skos:prefLabel"));
>        if(myfield.equals(query)) System.out.println("Query exactly matches
> the entire field.");
>        else System.out.println("The field contains the query.");
>
> Is there a better way?
>
> Thanks,
> Laura
>
> ---------------------------------------------------------------------
> 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