lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <deshmol-li...@yahoo.com>
Subject Re: Searching UN_TOKENIZED fields
Date Thu, 15 Jun 2006 14:20:00 GMT
Thanks Michael,

I general my queries could be more complex than the
example I outlined earlier, so I do need to use the
Query Parser. Hence, PerFieldAnalyzerWrapper and
KeywordAnalyzer seemed to do the trick for me.

PerFieldAnalyzerWrapper analyzer = new
PerFieldAnalyzerWrapper(new StandardAnalyzer());
analyzer.addAnalyzer("PROJECT", new
KeywordAnalyzer());
QueryParser parser = new QueryParser(defaultField,
analyzer);

~ amol




--- "Michael D. Curtin" <mike@curtin.com> wrote:

> deshmol-lists@yahoo.com 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.
> 
> --MDC
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail:
> java-user-help@lucene.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message