Hi Mikhail,

Sorry for having a few things unclear, I am creating a custom QParser, not 
QueryParser, that was a slip up. I believe you have answered my question 
though, and I think I have found a slightly better way to do the code anyway.

*Keep reading if curious. I could use some validation that what I am doing is 
not completely stupid:

I have been working on that query parser I have been sending emails out about 
for a special join query use case. The custom parser allows you to add filters 
to the child document set before the join happens. For example:

q={!rollup from=parent 
to=id}type:child&cfq=childField1:SomeValue&cfq=childField2:SomeValue

There is a custom extended facet component. I want to facet the child 
documents, not the final parent documents; except I want to facet ALL children, 
not just the children that were joined from.

The query parser also allows you to add another parameter that will apply to 
ALL children, both before the join, and for the facets. ex:
q={!rollup from=parent 
to=id}type:child&cfq=childField1:SomeValue&cfq=childField2:SomeValue&gcfq=childField3:someValue

This goes back to a use case I emailed about a while ago. I want my client to 
be able to execute a search like follows:
-Give me all shirts that have red items, only if it has red items in stock
-Give me the facets for all the in stock items for those products (aka 
including the yellow, blue, green items)

q={!rollup from=parent to=id}+(“shirts”….)&cfq=color:red&gcfq=inventory:[1 TO *]

Since that global filter is used multiple times. Once in the query parser, and 
once in the facet component, I just wanted to save it, and make sure I was 
saving it safely.

If anyone is curious, all my code is in a public github repository. 
(https://github.com/damos/SolrRollupQuery 
<https://github.com/damos/SolrRollupQuery>)

Thanks

Darin




In a nutshell, my query parser simply accepts a special filter query “sfq=<Some 
Query I desire>”. The parser executes the query and puts the docset into the 
request context to be used to filter multiple queries.

> On Dec 15, 2014, at 3:45 PM, Mikhail Khludnev <mkhlud...@griddynamics.com> 
> wrote:
> 
> Hello Darin,
> 
> Let me try to answer below,
> 
> On Mon, Dec 15, 2014 at 10:38 PM, Darin Amos <dari...@gmail.com> wrote:
>> 
>> Hello,
>> 
>> I have a simple question, is an instance of the QueryParser created for
>> every single request and is that object thread safe?
>> 
> QueryParser and QParser are request scope not-thread safe objects. eg
> QParser holds reference to SolrQueryRequest, and QueryParser holds parser
> field which is QParser.
> 
> 
>> 
>> I will try not to get into too much of the specifics but I have a custom
>> QueryParser
> 
> I wonder why. We used to extend QParserPlugin and QParser, rather than
> QueryParser.
> 
> 
>> and Search Component. Within my query parser when it is instantiated, I
>> execute a lucene search and use that docset to help build and filter my
>> main query. In my search component later on, I might need to build another
>> query with the query parser and use that same filter docset. I would rather
>> just hold onto the docset and reuse it rather than re-execute the query.
>> 
> 
> Here it's not clear whether you are talking about same request or about
> several ones. In case of former, you can pass whatever you need across your
> componets,parsers, handlers, responsewriters, etc via
> SolrQueryRequest.getContext().
> Sharing across requests are more tricky, check how Solr uses filterCache.
> The regular extensions uses
> https://wiki.apache.org/solr/SolrCaching#User.2FGeneric_Caches to cache
> DocSets by Strings or perhaps really heavy queries, which are also valid
> across requests.
> 
> 
>> 
>> Thanks!
>> 
>> Darin
>> 
>> 
> 
> -- 
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
> 
> <http://www.griddynamics.com>
> <mkhlud...@griddynamics.com>

Reply via email to