lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael D. Curtin" <>
Subject Re: Searching UN_TOKENIZED fields
Date Thu, 15 Jun 2006 14:09:15 GMT wrote:
> Hi,
> I have a field indexed as follows:
> new Field(name, value, Store.YES, Index.UN_TOKENIZED)
> I would like to search this field for exact match of
> the query term. Thus if, for instance in the above
> code snippet:
>   String name="PROJECT";
>   String value="Apache Lucene";
> I would like to get a hit in the following case:
>    query is PROJECT:"apache lucene"
> OR query is PROJECT:"Apache Lucene"
> OR query is PROJECT:"Apache Luc*"
> ...but not in the following case:
>    query is: PROJECT:apache
> OR query is: PROJECT:lucene
> With the Indexing call as above, and a query string of
> PROJECT:"Apache Lucene" I get 0 hits. I do get hits if
> I create the Field as TOKENIZED, but then it also
> matches the query PROJECT:apache which is not what I
> want.
> It is my understanding that I'm indexing correctly,
> but when I query, I need to indicate to the
> QueryParser that it should not tokenize the query
> string.
> Since the call:
> Term[] terms = ((PhraseQuery) query).getTerms();
> returns 2 terms, which for the above example are:
> "Apache" and "Lucene"
> Any ideas on how I can make this work?

If your queries are really as simple as this example, then you could just 
build queries up programmatically instead of using QueryParser, e.g. with new 
TermQuery().  Otherwise, you might want to look into using PerFieldAnalyzer 
and KeywordAnalyzer with QueryParser.


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

View raw message