lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: QParsePlugin not working on sharded collection
Date Wed, 03 Aug 2016 20:57:52 GMT
Right, I don't have the code in front of me right now, but I think
your issue is at the "aggregation" point. You also have to put
some code in the aggregation bits that pull your custom parts
from the sub-request packets and puts in the final packet,
"doing the right thing" in terms of assembling them into
something meaningful along the way (e.g. averaging "myvar"
or putting it in a list identified by shard or......).

I think if you fire the query at one of your shards with &distrib=false
you'll see your additions, which would demonstrate that your
filter is being found. I assume your custom jar is on the shards
or you'd get an exception (assuming you've pushed your
solrconfig to ZK).

Best,
Erick

On Wed, Aug 3, 2016 at 9:42 AM, tedsolr <tsmith@sciquest.com> wrote:
> I'm trying to verify that a very simple custom post filter will work on a
> sharded collection. So far it doesn't. Here are the search results on my
> single shard test collection:
>
> {
>   "responseHeader": {
>     "status": 0,
>     "QTime": 17
>   },
>   "thecountis": "946028",
>   "myvar": "hello",
>   "response": {
>     "numFound": 946028,
>     "start": 0,
>     "docs": [
> ...]
> }
>
> When I run against a two shard collection (same data set) it's as though the
> post filter doesn't exist. The results don't include my additions to the
> response:
>
> {
>   "responseHeader": {
>     "status": 0,
>     "QTime": 17
>   },
>   "response": {
>     "numFound": 946028,
>     "start": 0,
>     "docs": [
> ...]
> }
>
> Here's the solconfig.xml:
>
> ...
> <queryParser name="TedFilter" class="...TedPlugin" />
>    <requestHandler name="/ted" class="solr.SearchHandler">
>            <lst name="appends">
>                         <str name="fq">{!TedFilter myvar=hello}</str>
>                 </lst>
>    </requestHandler>
> ...
>
> And here's the simplest plugin I could write:
>
> public class TedPlugin extends QParserPlugin {
>         @Override
>         public void init(NamedList arg0) {
>         }
>
>         @Override
>         public QParser createParser(String arg0, final SolrParams arg1, final
> SolrParams arg2, final SolrQueryRequest arg3) {
>                 return new QParser(arg0, arg1, arg2, arg3) {
>
>                         @Override
>                         public Query parse() throws SyntaxError {
>                                 return new TedQuery(arg1, arg2, arg3);
>                         }
>                 };
>         }
> }
>
> public class TedQuery extends AnalyticsQuery {
>         private final String myvar;
>
>         TedQuery(SolrParams localParams, SolrParams params, SolrQueryRequest req) {
>                 myvar = localParams.get("myvar");
>         }
>
>         @Override
>         public DelegatingCollector getAnalyticsCollector(ResponseBuilder rb,
> IndexSearcher searcher) {
>                 return new TedCollector(myvar, rb);
>         }
>
>         @Override
>         public boolean equals(Object o) {
>                 if (o instanceof TedQuery) {
>                         TedQuery tq = (TedQuery) o;
>                         return Objects.equals(this.myvar, tq.myvar);
>                 }
>                 return false;
>         }
>
>         @Override
>         public int hashCode() {
>                 return myvar == null ? 1 : myvar.hashCode();
>         }
>
>
>         class TedCollector extends DelegatingCollector {
>                 ResponseBuilder rb;
>                 int count;
>                 String myvar;
>
>                 public TedCollector(String myvar, ResponseBuilder rb) {
>                         this.rb = rb;
>                         this.myvar = myvar;
>                 }
>
>                 @Override
>                 public void collect(int doc) throws IOException {
>                         count++;
>                         super.collect(doc);
>                 }
>
>                 @Override
>                 public void finish() throws IOException {
>                         rb.rsp.add("thecountis", String.valueOf(count));
>                         rb.rsp.add("myvar", myvar);
>
>                         if (super.delegate instanceof DelegatingCollector) {
>                                 ((DelegatingCollector) super.delegate).finish();
>                         }
>                 }
>         }
> }
>
> What am I doing wrong? Thanks!
> Ted
> v5.2.1 SolrCloud mode
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/QParsePlugin-not-working-on-sharded-collection-tp4290249.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message