You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Rosen Marinov <ro...@sirma.bg> on 2004/04/21 16:01:16 UTC

query

Does it query work:   "my name is \"Rosen\""?

Re: query

Posted by Morus Walter <mo...@tanto.de>.
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


Re: query

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Apr 21, 2004, at 12:17 PM, Rosen Marinov wrote:
>> 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

This is clean and green for me:

   public void testAbc() throws ParseException {
     Query query = QueryParser.parse("\"abc\"", "field", new 
SimpleAnalyzer());
     assertEquals("abc", query.toString("field"));
   }

Either you're using an old version of Lucene that is broken in this 
regard (I'm at CVS HEAD) or something else is fishy.

Note that a single term in quotes is optimized into a TermQuery, not a 
quoted PhraseQuery in the assert above.

> 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

Ranges with spaces in them doesn't work.  It is for single term ranges, 
not phrases that were tokenized.  If you indexed the entire "phrase" as 
a single term (Field.Keyword), then you could do an API RangeQuery, but 
QueryParser won't be happy.

QueryParser syntax is documented on the Lucene website if you need 
assistance with the type of syntax it supports.

	Erik


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


Re: query

Posted by Rosen Marinov <ro...@sirma.bg>.
> 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

thank you



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


Re: query

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Apr 21, 2004, at 10:01 AM, Rosen Marinov wrote:
> Does it query work:   "my name is \"Rosen\""?

http://wiki.apache.org/jakarta-lucene/AnalysisParalysis

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?


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