lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morus Walter <>
Subject RE: Query syntax on Keyword field question
Date Wed, 24 Mar 2004 07:43:14 GMT
Chad Small writes:
> Here is my attempt at a KeywordAnalyzer - although is not working?  Excuse the length
of the message, but wanted to give actual code.
> With this output:
> Analzying "HW-NCI_TOPICS"
>  org.apache.lucene.analysis.WhitespaceAnalyzer:
>  org.apache.lucene.analysis.SimpleAnalyzer:
>   [hw] [nci] [topics] 
>  org.apache.lucene.analysis.StopAnalyzer:
>   [hw] [nci] [topics] 
>  org.apache.lucene.analysis.standard.StandardAnalyzer:
>   [hw] [nci] [topics] 
>  healthecare.domain.lucenesearch.KeywordAnalyzer:
> query.ToString = category:HW -"nci topics" +space
> junit.framework.ComparisonFailure: HW-NCI_TOPICS kept as-is 
> Expected:+category:HW-NCI_TOPICS +space
> Actual  :category:HW -"nci topics" +space

Well query parser does not allow `-' within words currently.
So before your analyzer is called, query parser reads one word HW, a `-'
operator, one word NCI_TOPICS.
The latter is analyzed as "nci topics" because it's not in field category
anymore, I guess.

I suggested to change this. See

Either you escape the - using category:HW\-NCI_TOPICS in your query
(untested. and I don't know where the escape character will be removed)
or you apply my suggested change.

Another option for using keywords with query parser might be adding a
keyword syntax to the query parser.
Something like category:key("HW-NCI_TOPICS") or category="HW-NCI_TOPICS".


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message