lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markko Legonkov <maxl...@gmail.com>
Subject Re: How to use StreamingApi MultiFieldComparator?
Date Tue, 04 Oct 2016 21:18:45 GMT
the problem is in MultipleFieldEqualitor


@Override
public boolean isDerivedFrom(StreamComparator base){
if(null == base){ return false; }
if(base instanceof StreamComparator){
MultipleFieldComparator baseComps = (MultipleFieldComparator)base;
if(baseComps.getComps().length >= eqs.length){
for(int idx = 0; idx < eqs.length; ++idx){
if(!eqs[idx].isDerivedFrom(baseComps.getComps()[idx])){
return false;
}
}
return true;
}
}
return false;
}

it is called from ComplementStream

private void init(TupleStream streamA, TupleStream streamB, StreamEqualitor
eq) throws IOException {
this.streamA = new PushBackStream(streamA);
this.streamB = new PushBackStream(new UniqueStream(streamB, eq));
this.originalStreamB = streamB; // hold onto this for toExpression
this.eq = eq;
// streamA and streamB must both be sorted so that comp can be derived from
if(!eq.isDerivedFrom(streamA.getStreamSort()) || !eq.isDerivedFrom(streamB.
getStreamSort())){
throw new IOException("Invalid ComplementStream - both substream
comparators (sort) must be a superset of this stream's equalitor.");
}
}

If streamA.getStreamSort() or streamB.getStreamSort() returns
FieldComparator, then we get this casting exception.


Anyway.. if i add another sort field to search expressions, it works!
Is it bug or a feature?


max

On Mon, Oct 3, 2016 at 4:12 PM, Joel Bernstein <joelsolr@gmail.com> wrote:

> Ok, I'll test this out.
>
> Joel Bernstein
> http://joelsolr.blogspot.com/
>
> On Mon, Oct 3, 2016 at 4:40 AM, Markko Legonkov <maxlego@gmail.com> wrote:
>
> > here is the stacktrace
> >
> > java.io.IOException: Unable to construct instance of
> > org.apache.solr.client.solrj.io.stream.ComplementStream
> >         at org.apache.solr.client.solrj.io.stream.expr.StreamFactory.
> > createInstance(StreamFactory.java:323)
> >         at org.apache.solr.client.solrj.io.stream.expr.StreamFactory.
> > constructStream(StreamFactory.java:185)
> >         at org.apache.solr.client.solrj.io.stream.expr.StreamFactory.
> > constructStream(StreamFactory.java:178)
> >         at org.apache.solr.handler.StreamHandler.handleRequestBody(
> > StreamHandler.java:185)
> >         at org.apache.solr.handler.RequestHandlerBase.handleRequest(
> > RequestHandlerBase.java:154)
> >         at org.apache.solr.core.SolrCore.execute(SolrCore.java:2089)
> >         at org.apache.solr.servlet.HttpSolrCall.execute(
> > HttpSolrCall.java:652)
> >         at org.apache.solr.servlet.HttpSolrCall.call(
> > HttpSolrCall.java:459)
> >         at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
> > SolrDispatchFilter.java:257)
> >         at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
> > SolrDispatchFilter.java:208)
> >         at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
> > doFilter(ServletHandler.java:1668)
> >         at org.eclipse.jetty.servlet.ServletHandler.doHandle(
> > ServletHandler.java:581)
> >         at org.eclipse.jetty.server.handler.ScopedHandler.handle(
> > ScopedHandler.java:143)
> >         at org.eclipse.jetty.security.SecurityHandler.handle(
> > SecurityHandler.java:548)
> >         at org.eclipse.jetty.server.session.SessionHandler.
> > doHandle(SessionHandler.java:226)
> >         at org.eclipse.jetty.server.handler.ContextHandler.
> > doHandle(ContextHandler.java:1160)
> >         at org.eclipse.jetty.servlet.ServletHandler.doScope(
> > ServletHandler.java:511)
> >         at org.eclipse.jetty.server.session.SessionHandler.
> > doScope(SessionHandler.java:185)
> >         at org.eclipse.jetty.server.handler.ContextHandler.
> > doScope(ContextHandler.java:1092)
> >         at org.eclipse.jetty.server.handler.ScopedHandler.handle(
> > ScopedHandler.java:141)
> >         at org.eclipse.jetty.server.handler.ContextHandlerCollection.
> > handle(ContextHandlerCollection.java:213)
> >         at org.eclipse.jetty.server.handler.HandlerCollection.
> > handle(HandlerCollection.java:119)
> >         at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
> > HandlerWrapper.java:134)
> >         at org.eclipse.jetty.server.Server.handle(Server.java:518)
> >         at org.eclipse.jetty.server.HttpChannel.handle(
> > HttpChannel.java:308)
> >         at org.eclipse.jetty.server.HttpConnection.onFillable(
> > HttpConnection.java:244)
> >         at org.eclipse.jetty.io.AbstractConnection$
> ReadCallback.succeeded(
> > AbstractConnection.java:273)
> >         at org.eclipse.jetty.io.FillInterest.fillable(
> > FillInterest.java:95)
> >         at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(
> > SelectChannelEndPoint.java:93)
> >         at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.
> > produceAndRun(ExecuteProduceConsume.java:246)
> >         at org.eclipse.jetty.util.thread.strategy.
> > ExecuteProduceConsume.run(ExecuteProduceConsume.java:156)
> >         at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
> > QueuedThreadPool.java:654)
> >         at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
> > QueuedThreadPool.java:572)
> >         at java.lang.Thread.run(Thread.java:745)
> > Caused by: java.lang.reflect.InvocationTargetException
> >         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > Method)
> >         at sun.reflect.NativeConstructorAccessorImpl.newInstance(
> > NativeConstructorAccessorImpl.java:62)
> >         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> > DelegatingConstructorAccessorImpl.java:45)
> >         at java.lang.reflect.Constructor.newInstance(Constructor.java:
> 422)
> >         at org.apache.solr.client.solrj.io.stream.expr.StreamFactory.
> > createInstance(StreamFactory.java:316)
> >         ... 33 more
> > Caused by: java.lang.ClassCastException:
> > org.apache.solr.client.solrj.io.comp.FieldComparator cannot be cast to
> > org.apache.solr.client.solrj.io.comp.MultipleFieldComparator
> >         at org.apache.solr.client.solrj.io.eq.MultipleFieldEqualitor.
> > isDerivedFrom(MultipleFieldEqualitor.java:99)
> >         at org.apache.solr.client.solrj.io.stream.ReducerStream.init(
> > ReducerStream.java:132)
> >         at org.apache.solr.client.solrj.io.stream.ReducerStream.<init>
> > (ReducerStream.java:69)
> >         at org.apache.solr.client.solrj.io.stream.UniqueStream.init(
> > UniqueStream.java:83)
> >         at org.apache.solr.client.solrj.io.stream.UniqueStream.<init>(
> > UniqueStream.java:55)
> >         at org.apache.solr.client.solrj.io.stream.ComplementStream.
> > init(ComplementStream.java:81)
> >         at org.apache.solr.client.solrj.io.stream.ComplementStream.<
> > init>(ComplementStream.java:73)
> >         ... 38 more
> >
> >
> > On Sun, Oct 2, 2016 at 12:59 AM, Joel Bernstein <joelsolr@gmail.com>
> > wrote:
> >
> > > Hi can you attach the stack traces in the logs? I'd like to see where
> > this
> > > exception coming, this appears to be a bug.
> > >
> > > I'll also need to dig into your expression and see if there is an issue
> > > with the syntax.
> > >
> > > Joel Bernstein
> > > http://joelsolr.blogspot.com/
> > >
> > > On Sat, Oct 1, 2016 at 2:29 PM, Markko Legonkov <maxlego@gmail.com>
> > wrote:
> > >
> > > > Hi
> > > >
> > > > What i would like to achieve is that i want to filter out all
> products
> > > > which have different prices on two given dates.
> > > > Here is a sample expression
> > > >
> > > > leftOuterJoin(
> > > >   search(
> > > >     products,
> > > >     q="*:*",
> > > >     fq="product_id_i:1 AND product_name_s:test",
> > > >     fl="id, product_id_i, product_name_s,sale_price_d",
> > > >     sort="product_id_i asc"
> > > >   ),
> > > >   select(
> > > >     search(
> > > >       products,
> > > >       q="product_id_i:1 AND product_name_s:Test",
> > > >       fl="id, product_id_i, product_name_s,sale_price_d",
> > > >       sort="product_id_i asc"
> > > >     ),
> > > >     id as c_id,
> > > >     product_id_i as c_product_id_i,
> > > >     product_name_s as c_product_name_s,
> > > >     sale_price_d as c_sale_price_d
> > > >   ),
> > > >   on="product_id_i=c_product_id_i, sale_price_d!=c_sale_price_d"
> > > > )
> > > >
> > > > I am using solr 6.2.0
> > > > And the result i get from solr is:
> > > > {
> > > >   "result-set": {
> > > >     "docs": [
> > > >       {
> > > >         "EXCEPTION": "org.apache.solr.client.solrj.
> > > io.comp.FieldComparator
> > > > cannot be cast to
> > > > org.apache.solr.client.solrj.io.comp.MultipleFieldComparator",
> > > >         "EOF": true
> > > >       }
> > > >     ]
> > > >   }
> > > > }
> > > >
> > > > Do i have to configure something in solr that it knows it has to use
> > > > MultipleFieldComparator?
> > > >
> > > > Regards
> > > > Max
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message