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 Ankit Murarka <an...@rancoretech.com> on 2013/09/10 08:49:41 UTC

Providing special characters in input when using QueryParser.

Hello,
         I am using StandardAnalyzer for indexing all the documents.

While Searching say for Boolean/Wildcard/Prefix query, I am using 
*QueryParser* for the user supplied input.

But when I supply / as an input along with some characters like:

<param name="name" value="WSTFGH1028"/>\

I get a lexcial error due to presence of special characters in the code.

When I supply the same phrase in PhraseQuery, I get the required hit.. 
Understood that PhraseQuery and QueryParser handles query differently.

How can I achieve this. Accepting special characters also in user 
supplied inputs. I cannot make any changes in the indexing process . 
Also inputs like this will be very common from the user end..

Kindly guide.

TIA.

-- 
TIA
Regards

Ankit Murarka

"What lies behind us and what lies before us are tiny matters compared with what lies within us"


Re: Providing special characters in input when using QueryParser.

Posted by Ankit Murarka <an...@rancoretech.com>.
Ok..The problem seems to be solved.. Using the escape method of 
QueryParser, I am able to parse the given input with special characters 
also.

But if this leads to another pitfall someone may please guide..

On 9/10/2013 12:19 PM, Ankit Murarka wrote:
> Hello,
>         I am using StandardAnalyzer for indexing all the documents.
>
> While Searching say for Boolean/Wildcard/Prefix query, I am using 
> *QueryParser* for the user supplied input.
>
> But when I supply / as an input along with some characters like:
>
> <param name="name" value="WSTFGH1028"/>\
>
> I get a lexcial error due to presence of special characters in the code.
>
> When I supply the same phrase in PhraseQuery, I get the required hit.. 
> Understood that PhraseQuery and QueryParser handles query differently.
>
> How can I achieve this. Accepting special characters also in user 
> supplied inputs. I cannot make any changes in the indexing process . 
> Also inputs like this will be very common from the user end..
>
> Kindly guide.
>
> TIA.
>


-- 
Regards

Ankit Murarka

"What lies behind us and what lies before us are tiny matters compared with what lies within us"


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