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 Jamie Johnson <je...@gmail.com> on 2014/02/20 03:43:35 UTC

Limiting the fields a user can query on

Is there a way to limit the fields a user can query by when using the
standard query parser or a way to get all fields/terms that make up a query
without writing custom code for each query subclass?

Re: Limiting the fields a user can query on

Posted by Jamie Johnson <je...@gmail.com>.
I would be fine with throwing a parse exception or excluding the particular
clause.  I will look at the StandardQueryNodeProcessorPipeline as well as
Hoss' suggestion.  Thank you very much!


On Thu, Feb 20, 2014 at 4:20 AM, Trejkaz <tr...@trypticon.org> wrote:

> On Thu, Feb 20, 2014 at 1:43 PM, Jamie Johnson <je...@gmail.com> wrote:
> > Is there a way to limit the fields a user can query by when using the
> > standard query parser or a way to get all fields/terms that make up a
> query
> > without writing custom code for each query subclass?
>
> If you mean StandardQueryParser, you could subclass
> StandardQueryNodeProcessorPipeline and add one more processor into the
> pipeline which looks for instances of FieldableNode. That should cover
> any kind of query node which can have a field on it.
>
> TX
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Limiting the fields a user can query on

Posted by Trejkaz <tr...@trypticon.org>.
On Thu, Feb 20, 2014 at 1:43 PM, Jamie Johnson <je...@gmail.com> wrote:
> Is there a way to limit the fields a user can query by when using the
> standard query parser or a way to get all fields/terms that make up a query
> without writing custom code for each query subclass?

If you mean StandardQueryParser, you could subclass
StandardQueryNodeProcessorPipeline and add one more processor into the
pipeline which looks for instances of FieldableNode. That should cover
any kind of query node which can have a field on it.

TX

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


Re: Limiting the fields a user can query on

Posted by Chris Hostetter <ho...@fucit.org>.
: Is there a way to limit the fields a user can query by when using the
: standard query parser or a way to get all fields/terms that make up a query
: without writing custom code for each query subclass?

"limit" in what way?  do you want to throw a parse error if they give you 
"field_you_do_not_allow:foo*" or do you want to treat th entire string 
(including the colon) as a prefix? or do you want to ignore the clause 
entirely?

depending on your goal, you could subclass the QueryParser and override 
the various methods to throw and exception (or change what query gets 
produced) based on the field name passed to you -- or you could use an 
IndexReader wrapper that hides the existence of the terms in the fields 
you don't want to allow so the queries re-write to no-ops.



-Hoss
http://www.lucidworks.com/

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