You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Dipti Srivastava <Di...@apollogrp.edu> on 2012/01/20 23:52:28 UTC

Validating solr user query

Hi All,
I ma using HTTP/JSON to search my documents in Solr. Now the client provides the query on which the search is based.
What is a good way to validate the query string provided by the user.

On the other hand, if I want the user to build this query using some Solr api instead of preparing a lucene query string which API can I use for this?
I looked into
SolrQuery in SolrJ but it does not appear to have a way to specify the more complex queries with the boolean operators and operators such as ~,+,- etc.

Basically, I am trying to avoid running into bad query strings built by the caller.

Thanks!
Dipti

________________________________
This message is private and confidential. If you have received it in error, please notify the sender and remove it from your system.


Re: Validating solr user query

Posted by Erick Erickson <er...@gmail.com>.
Good luck on that <G>....

If you allow free-form input, bad queries are just going to happen. To prevent
this from getting to Solr, you essentially have to reproduce the
entire Solr/Lucene
parser. So why not just let the parser to it for you and present some pretty
message to the user?

The other thing you can do is build your own "advanced query page" that guides
the user through adding parentheses, ands, ors, nots, fuzzy, all that
jazz, but that's
often really painful to do.

But other than making a UI that makes it difficult to make bad queries
or parsing
the query, you're pretty much stuck...

Best
Erick

On Fri, Jan 20, 2012 at 2:52 PM, Dipti Srivastava
<Di...@apollogrp.edu> wrote:
> Hi All,
> I ma using HTTP/JSON to search my documents in Solr. Now the client provides the query on which the search is based.
> What is a good way to validate the query string provided by the user.
>
> On the other hand, if I want the user to build this query using some Solr api instead of preparing a lucene query string which API can I use for this?
> I looked into
> SolrQuery in SolrJ but it does not appear to have a way to specify the more complex queries with the boolean operators and operators such as ~,+,- etc.
>
> Basically, I am trying to avoid running into bad query strings built by the caller.
>
> Thanks!
> Dipti
>
> ________________________________
> This message is private and confidential. If you have received it in error, please notify the sender and remove it from your system.
>

Re: Validating solr user query

Posted by Erick Erickson <er...@gmail.com>.
No. Look in solrconfig.xml for the
<requestHandler ..... default="true" /> and you'll see
that it's not. Appending &debugQuery=on will also
show this.....

Best
Erick

On Fri, Jan 27, 2012 at 12:18 PM, Dipti Srivastava
<Di...@apollogrp.edu> wrote:
> Hi Chantal,
> Thanks for your response. Isn't the DisMaxQParserPlugin the default
> parser, when none is specified? I am using Solr version 3.4.
> Thanks,
> Dipti
>
> On 1/23/12 3:33 AM, "Chantal Ackermann" <ch...@btelligent.de>
> wrote:
>
>>Hi Dipti,
>>
>>just to make sure: are you aware of
>>
>>http://wiki.apache.org/solr/DisMaxQParserPlugin
>>
>>This will handle the user input in a very conventional and user friendly
>>way. You just have to specify on which fields you want it to search.
>>With the 'mm' parameter you have a powerfull option to specify how much
>>of a search query has to match (more flexible than defining a default
>>operator).
>>
>>Cheers,
>>Chantal
>>
>>On Fri, 2012-01-20 at 23:52 +0100, Dipti Srivastava wrote:
>>> Hi All,
>>> I ma using HTTP/JSON to search my documents in Solr. Now the client
>>>provides the query on which the search is based.
>>> What is a good way to validate the query string provided by the user.
>>>
>>> On the other hand, if I want the user to build this query using some
>>>Solr api instead of preparing a lucene query string which API can I use
>>>for this?
>>> I looked into
>>> SolrQuery in SolrJ but it does not appear to have a way to specify the
>>>more complex queries with the boolean operators and operators such as
>>>~,+,- etc.
>>>
>>> Basically, I am trying to avoid running into bad query strings built by
>>>the caller.
>>>
>>> Thanks!
>>> Dipti
>>>
>>> ________________________________
>>> This message is private and confidential. If you have received it in
>>>error, please notify the sender and remove it from your system.
>>>
>>
>>
>
>
> This message is private and confidential. If you have received it in error, please notify the sender and remove it from your system.
>
>

Re: Validating solr user query

Posted by Dipti Srivastava <Di...@apollogrp.edu>.
Hi Chantal,
Thanks for your response. Isn't the DisMaxQParserPlugin the default
parser, when none is specified? I am using Solr version 3.4.
Thanks,
Dipti

On 1/23/12 3:33 AM, "Chantal Ackermann" <ch...@btelligent.de>
wrote:

>Hi Dipti,
>
>just to make sure: are you aware of
>
>http://wiki.apache.org/solr/DisMaxQParserPlugin
>
>This will handle the user input in a very conventional and user friendly
>way. You just have to specify on which fields you want it to search.
>With the 'mm' parameter you have a powerfull option to specify how much
>of a search query has to match (more flexible than defining a default
>operator).
>
>Cheers,
>Chantal
>
>On Fri, 2012-01-20 at 23:52 +0100, Dipti Srivastava wrote:
>> Hi All,
>> I ma using HTTP/JSON to search my documents in Solr. Now the client
>>provides the query on which the search is based.
>> What is a good way to validate the query string provided by the user.
>>
>> On the other hand, if I want the user to build this query using some
>>Solr api instead of preparing a lucene query string which API can I use
>>for this?
>> I looked into
>> SolrQuery in SolrJ but it does not appear to have a way to specify the
>>more complex queries with the boolean operators and operators such as
>>~,+,- etc.
>>
>> Basically, I am trying to avoid running into bad query strings built by
>>the caller.
>>
>> Thanks!
>> Dipti
>>
>> ________________________________
>> This message is private and confidential. If you have received it in
>>error, please notify the sender and remove it from your system.
>>
>
>


This message is private and confidential. If you have received it in error, please notify the sender and remove it from your system.



Re: Validating solr user query

Posted by Chantal Ackermann <ch...@btelligent.de>.
Hi Dipti,

just to make sure: are you aware of

http://wiki.apache.org/solr/DisMaxQParserPlugin

This will handle the user input in a very conventional and user friendly
way. You just have to specify on which fields you want it to search.
With the 'mm' parameter you have a powerfull option to specify how much
of a search query has to match (more flexible than defining a default
operator).

Cheers,
Chantal

On Fri, 2012-01-20 at 23:52 +0100, Dipti Srivastava wrote:
> Hi All,
> I ma using HTTP/JSON to search my documents in Solr. Now the client provides the query on which the search is based.
> What is a good way to validate the query string provided by the user.
> 
> On the other hand, if I want the user to build this query using some Solr api instead of preparing a lucene query string which API can I use for this?
> I looked into
> SolrQuery in SolrJ but it does not appear to have a way to specify the more complex queries with the boolean operators and operators such as ~,+,- etc.
> 
> Basically, I am trying to avoid running into bad query strings built by the caller.
> 
> Thanks!
> Dipti
> 
> ________________________________
> This message is private and confidential. If you have received it in error, please notify the sender and remove it from your system.
>