lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morus Walter <morus.wal...@tanto.de>
Subject Re: query
Date Thu, 22 Apr 2004 06:28:22 GMT
Rosen Marinov writes:
> > Short answer: it depends.
> > 
> > Questions for you to answer:
> > What field type and analyzer did you use during indexing?  What 
> > analyzer used with QueryParser?  What does the generated Query.toString 
> > return?
> 
> in both cases SimpleAnalyzer
> QueryParser.parse("\"abc\"") throws an exception and i can't see what does
> Query.toString return in this case
> 
> what analizer should i use if i want to execute folowing queries:
>    simple key word seach (+bush -president , etc)
>    range queries including " characters in searching values
> 
The problem is, that Phrases are defined as
| <QUOTED:     "\"" (~["\""])+ "\"">
in the query parser.
So you cannot have a " inside (even escaped).
I guess that's a bug.
It should read something like
| <QUOTED:     "\"" (~["\""] | "\\\"")+ "\"">
(untested).

But that shouldn't apply to QueryParser.parse("\"abc\"") (parsing "abc").
Only to QueryParser.parse("\"\\\"abc\\\"\"") (parsing "\"abc\"").

If you used SimpleAnalyzer (same for StandardAnalyzer) quotes got stripped
anyway. 
Since you cannot search for things, that didn't got indexed, searching
for `foo "bar" bla' and `foo bar bla' will be the same.

The answer to your second question 
> Is there more sly way to get the doc with exact maching this title? (for info: my titles
are unique)
is to skip query parser and create the query as a phrase query yourself.
But this requires tokenization in the same way as it was done when indexing
as well. Otherwise you might end with no results.
If you have a lot of exact title queries, it might be worth to consider
having a keyword field (that means no tokenization) for this data (in that
case, you won't have to care about tokenizers and might create the query
as a single TermQuery). There's no support for keyword queries in the 
query parser though.

HTH
	Morus


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


Mime
View raw message