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 Terence Lai <tl...@trekspace.com> on 2004/11/24 05:43:27 UTC
Help on the Query Parser
Hi all,
I am trying to use the QueryParser.parse() to parse a query string like "java* developer". Note that I want the wildcard string, java*, followed by the word developer. The following is the code.
-------------
String qryStr = "\"java* developer\"";
String fieldname = "text";
StandardAnalyzer analyzer = new StandAnalyzer();
Query qry = org.apache.lucene.queryParser.QueryParser.parse(qryStr, fieldname, analyzer);
-------------
When I do a qryStr.toString() to print out the contents, I got the following output:
---------------------
text:"java developer"
---------------------
Look likes that the wildcard query disappeared. In fact, I am expecting text:"java* developer" to be returned. It seems to me that the QueryParser cannot handle the wildcard within a quoted String.
Does anyone has a solution on this? Am I missing something in the code?
Thanks,
Terence
----------------------------------------------------------
Get your free email account from http://www.trekspace.com
Your Internet Virtual Desktop!
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: Help on the Query Parser
Posted by Daniel Naber <da...@t-online.de>.
On Wednesday 24 November 2004 08:16, Morus Walter wrote:
> Lucene itself doesn't handle wildcards within phrases.
This can be added using PhrasePrefixQuery (which is slightly misnamed):
http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/PhrasePrefixQuery.html
Regards
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: Help on the Query Parser
Posted by Morus Walter <mo...@tanto.de>.
Terence Lai writes:
>
> Look likes that the wildcard query disappeared. In fact, I am expecting text:"java* developer" to be returned. It seems to me that the QueryParser cannot handle the wildcard within a quoted String.
>
That's not just QueryParser.
Lucene itself doesn't handle wildcards within phrases.
You could have a query text:"java* developer" if '*' isn't removed by the
analyzer. But it would only search for the token 'java*' not any expansion of
that. I guess this is not, what you want.
Morus
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org