I am running this in a unit test which deletes the collection after the
test is over. So every new test run gets a fresh collection.

It is a very simple test where I am first indexing a couple of parent
documents with few children and then testing an atomic update on one parent
as I have posted in my previous message. (using UpdateRequest)

I am not sure if I am triggering the atomic update correctly, do you see
any potential issue in that code?

I noticed something in the documentation here.
https://lucene.apache.org/solr/guide/8_5/indexing-nested-documents.html#indexing-nested-documents

<fieldType name="_nest_path_" class="solr.NestPathField" /> <field
name="_nest_path_" type="*nest_path*" />

field_type is declared with name *"_nest_path_"* whereas field is declared
with type *"nest_path". *

Is this intentional? or should it be as follows?

<fieldType name="_nest_path_" class="solr.NestPathField" /> <field
name="_nest_path_" type="* _nest_path_ *" />

Also, should we explicitly set index=true and store=true on _nest_path_
and _nest_parent_ fields?



On Thu, Sep 17, 2020 at 1:17 PM Alexandre Rafalovitch <arafa...@gmail.com>
wrote:

> Did you reindex the original document after you added a new field? If
> not, then the previously indexed content is missing it and your code
> paths will get out of sync.
>
> Regards,
>    Alex.
> P.s. I haven't done what you are doing before, so there may be
> something I am missing myself.
>
>
> On Thu, 17 Sep 2020 at 12:46, Pratik Patel <pra...@semandex.net> wrote:
> >
> > Thanks for your reply Alexandre.
> >
> > I have "_root_" and "_nest_path_" fields in my schema but not
> > "_nest_parent_".
> >
> >
> > <!-- If you don't use child/nested documents, then you should remove the
> > next two fields:  -->
> > <!-- for nested documents (minimal; points to root document) -->
> > <field name="_root_" type="string" indexed="true" stored="true"
> > docValues="false" />
> > <!-- for nested documents (relationship tracking) -->
> > <field name="_nest_path_" type="_nest_path_" /><fieldType
> > name="_nest_path_" class="solr.NestPathField" />
> >
> > I ran my test after adding the "_nest_parent_" field and I am not getting
> > NPE any more which is good. Thanks!
> >
> > But looking at the documents in the index, I see that after the atomic
> > update, now there are two children documents with the same id. One
> document
> > has old values and another one has new values. Shouldn't they be merged
> > based on the "id"? Do we need to specify anything else in the request to
> > ensure that documents are merged/updated and not duplicated?
> >
> > For your reference, below is the test I am running now.
> >
> >             // update field of one child doc
> >             SolrInputDocument sdoc = new SolrInputDocument(  );
> >             sdoc.addField( "id", testChildPOJO.id() );
> >             sdoc.addField( "conceptid", testChildPOJO.conceptid() );
> >             sdoc.addField( "storeid", "foo" );
> >             sdoc.setField( "fieldName",
> > java.util.Collections.singletonMap("set", Collections.list("bar" ) ));
> >
> >             final UpdateRequest req = new UpdateRequest();
> >             req.withRoute( pojo1.id() );    // parent id
> >             req.add(sdoc);
> >
> >             collection.client.request( req,
> collection.getCollectionName()
> > );
> >             collection.client.commit();
> >
> >
> > Resulting documents :
> >
> > {id=c1_child1, conceptid=c1, storeid=s1,
> fieldName=c1_child1_field_value1,
> > startTime=Mon Sep 07 12:40:37 EDT 2020, integerField_iDF=10,
> > booleanField_bDF=true, _root_=abcd, _version_=1678099970090074112}
> > {id=c1_child1, conceptid=c1, storeid=foo, fieldName=bar, startTime=Mon
> Sep
> > 07 12:40:37 EDT 2020, integerField_iDF=10, booleanField_bDF=true,
> > _root_=abcd, _version_=1678099970405695488}
> >
> >
> >
> >
> >
> >
> > On Thu, Sep 17, 2020 at 12:01 PM Alexandre Rafalovitch <
> arafa...@gmail.com>
> > wrote:
> >
> > > Can you double-check your schema to see if you have all the fields
> > > required to support nested documents. You are supposed to get away
> > > with just _root_, but really you should also include _nest_path and
> > > _nest_parent_. Your particular exception seems to be triggering
> > > something (maybe a bug) related to - possibly - missing _nest_path_
> > > field.
> > >
> > > See:
> > >
> https://lucene.apache.org/solr/guide/8_5/indexing-nested-documents.html#indexing-nested-documents
> > >
> > > Regards,
> > >    Alex.
> > >
> > > On Wed, 16 Sep 2020 at 13:28, Pratik Patel <pra...@semandex.net>
> wrote:
> > > >
> > > > Hello Everyone,
> > > >
> > > > I am trying to update a field of a child document using atomic
> updates
> > > > feature. I am using solr and solrJ version 8.5.0
> > > >
> > > > I have ensured that my schema satisfies the conditions for atomic
> updates
> > > > and I am able to do atomic updates on normal documents but with
> nested
> > > > child documents, I am getting a Null Pointer Exception. Following is
> the
> > > > simple test which I am trying.
> > > >
> > > > TestPojo      pojo1          = new TestPojo().cId( "abcd" )
> > > > >                                                  .conceptid( "c1" )
> > > > >                                                  .storeid( storeId
> )
> > > > >                                                  .testChildPojos(
> > > > > Collections.list( testChildPOJO, testChildPOJO2,
> > > > >
> > > testChildPOJO3 )
> > > > > );
> > > > > TestChildPOJO                testChildPOJO = new
> TestChildPOJO().cId(
> > > > > "c1_child1" )
> > > > >                                                       .conceptid(
> "c1"
> > > )
> > > > >                                                       .storeid(
> > > storeId )
> > > > >                                                       .fieldName(
> > > > > "c1_child1_field_value1" )
> > > > >                                                       .startTime(
> > > > > Date.from( now.minus( 10, ChronoUnit.DAYS ) ) )
> > > > >
> > >  .integerField_iDF(
> > > > > 10 )
> > > > >
> > > > > .booleanField_bDF(true);
> > > > > // index pojo1 with child testChildPOJO
> > > > > SolrInputDocument sdoc = new SolrInputDocument();
> > > > > sdoc.addField( "_route_", pojo1.cId() );
> > > > > sdoc.addField( "id", testChildPOJO.cId() );
> > > > > sdoc.addField( "conceptid", testChildPOJO.conceptid() );
> > > > > sdoc.addField( "storeid", testChildPOJO.cId() );
> > > > > sdoc.setField( "fieldName",
> java.util.Collections.singletonMap("set",
> > > > > Collections.list(testChildPOJO.fieldName() + postfix) ) ); //
> modify
> > > field
> > > > > "fieldName"
> > > > > collection.client.add( sdoc );   // results in NPE!
> > > >
> > > >
> > > > Stack Trace:
> > > >
> > > > ERROR org.apache.solr.client.solrj.impl.BaseCloudSolrClient -
> Request to
> > > > > collection [collectionTest2] failed due to (500)
> > > > >
> org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:
> > > Error
> > > > > from server at
> > > > > http://172.15.1.100:8081/solr/collectionTest2_shard1_replica_n1:
> > > > > java.lang.NullPointerException
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.AtomicUpdateDocumentMerger.getFieldFromHierarchy(AtomicUpdateDocumentMerger.java:308)
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.AtomicUpdateDocumentMerger.mergeChildDoc(AtomicUpdateDocumentMerger.java:405)
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.DistributedUpdateProcessor.getUpdatedDocument(DistributedUpdateProcessor.java:711)
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.DistributedUpdateProcessor.doVersionAdd(DistributedUpdateProcessor.java:374)
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.DistributedUpdateProcessor.lambda$versionAdd$0(DistributedUpdateProcessor.java:339)
> > > > > at
> > > org.apache.solr.update.VersionBucket.runWithLock(VersionBucket.java:50)
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:339)
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:225)
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.DistributedZkUpdateProcessor.processAdd(DistributedZkUpdateProcessor.java:245)
> > > > > at
> > > > >
> > >
> org.apache.solr.update.processor.LogUpdateProcessorFactory$LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:103)
> > > > > at
> > > > >
> > >
> org.apache.solr.handler.loader.JavabinLoader$1.update(JavabinLoader.java:110)
> > > > > at
> > > > >
> > >
> org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec$StreamingCodec.readOuterMostDocIterator(JavaBinUpdateRequestCodec.java:332)
> > > > > at
> > > > >
> > >
> org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec$StreamingCodec.readIterator(JavaBinUpdateRequestCodec.java:281)
> > > > > at
> > > > >
> > >
> org.apache.solr.common.util.JavaBinCodec.readObject(JavaBinCodec.java:338)
> > > > > at
> > > org.apache.solr.common.util.JavaBinCodec.readVal(JavaBinCodec.java:283)
> > > > > at
> > > > >
> > >
> org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec$StreamingCodec.readNamedList(JavaBinUpdateRequestCodec.java:236)
> > > > > at
> > > > >
> > >
> org.apache.solr.common.util.JavaBinCodec.readObject(JavaBinCodec.java:303)
> > > > > at
> > > org.apache.solr.common.util.JavaBinCodec.readVal(JavaBinCodec.java:283)
> > > > > at
> > > > >
> > >
> org.apache.solr.common.util.JavaBinCodec.unmarshal(JavaBinCodec.java:196)
> > > > > at
> > > > >
> > >
> org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec.unmarshal(JavaBinUpdateRequestCodec.java:127)
> > > > > at
> > > > >
> > >
> org.apache.solr.handler.loader.JavabinLoader.parseAndLoadDocs(JavabinLoader.java:122)
> > > > > at
> > >
> org.apache.solr.handler.loader.JavabinLoader.load(JavabinLoader.java:70)
> > > > > at
> > > > >
> > >
> org.apache.solr.handler.UpdateRequestHandler$1.load(UpdateRequestHandler.java:97)
> > > > > at
> > > > >
> > >
> org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:68)
> > > > > at
> > > > >
> > >
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:211)
> > > > > at org.apache.solr.core.SolrCore.execute(SolrCore.java:2596)
> > > > > at
> org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:802)
> > > > > at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:579)
> > > > > at
> > > > >
> > >
> org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:420)
> > > > > at
> > > > >
> > >
> org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:352)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1596)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:545)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:590)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1607)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1297)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:485)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1577)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1212)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:221)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.InetAccessHandler.handle(InetAccessHandler.java:177)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:322)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
> > > > > at org.eclipse.jetty.server.Server.handle(Server.java:500)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
> > > > > at
> org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:547)
> > > > > at
> org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:270)
> > > > > at
> > > > > org.eclipse.jetty.io
> > > .AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
> > > > > at org.eclipse.jetty.io
> .FillInterest.fillable(FillInterest.java:103)
> > > > > at org.eclipse.jetty.io
> > > .ChannelEndPoint$2.run(ChannelEndPoint.java:117)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:388)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
> > > > > at
> > > > >
> > >
> org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
> > > > > at java.lang.Thread.run(Thread.java:745)
> > > > > , retry=0 commError=false errorCode=500
> > > >
> > > >
> > > >
> > > >
> > > > I am able to add a parent child block successfully but with nested
> docs
> > > the
> > > > field update fails.  I saw a similar looking JIRA
> > > > https://issues.apache.org/jira/browse/SOLR-13523 but it looks like
> its
> > > > already fixed in 8.5.0.
> > > >
> > > > Any idea what's wrong here?
> > > >
> > > > Thanks.
> > >
>

Reply via email to