Hi Matthew, The ref guide has an explanation of the different options for sending documents as JSON.
https://solr.apache.org/guide/solr/latest/indexing-guide/indexing-with-update-handlers.html#json-formatted-index-updates My personal preference is to stick with the /update handler path and Solr-Style JSON update commands. (Maybe that's because they're a mapping of the XML update commands that I was already familiar with.) It's a bit more verbose to include {"add":{"doc":{...}} but I find it avoids confusion. Does your schema have a <uniqueKey>...</uniqueKey> field defined and is that field required="true"? I've never tried nested documents without this. Thomas Op do 3 nov. 2022 om 00:28 schreef Matthew Castrigno <castr...@slhs.org>: > Hi Thomas, > > I am confused by your comments of "custom" JSON and "SOLR" JSON to me > there is only one JSON. > I cannot modify the format of this JSON object. How can I configure SOLR > to index this object as is ? > > When I attempt to wrap this JSON with an array wrapper SOLR thinks I am > trying to do an atomic update. > Thank you as always for your assistance, it is greatly appreciated. > > { > "responseHeader":{ > "status":400, > "QTime":3}, > "error":{ > "metadata":[ > "error-class","org.apache.solr.common.SolrException", > "root-error-class","org.apache.solr.common.SolrException"], > "msg":"Error:[doc=2ff99d1a-a21b-4391-9c47-af2865acb753] Unknown > operation for the an atomic update: Page", > "code":400}} > > curl --location --request GET 'place_holder_email:8983/solr/talix/update' \ > --header 'Content-Type: application/json' \ > --data-raw '[{ > "partner": "88027688-62c4-459a-b4d5-a8ecf9edd1bf", > "command": "add", > "doc_id": "2ff99d1a-a21b-4391-9c47-af2865acb753", > "content": { > "Page": { > "Id": "2ff99d1a-a21b-4391-9c47-af2865acb753", > "Name": "Ronald McDonald House Idaho meals", > "Url": > "/blogs/st-lukes/news-and-community/2021/jan/ronald-mcdonald-house-idaho-meals", > "Date": "2022-10-03T12:30:17.3388537", > "ContentType": "Blog", > "Body": { > "Fields": [ > { "Name": "Heading Background Image", "Type": "Image", "Value": > "" }, > { "Name": "Tile Wide Image", "Type": "Image", "Value": "" }, > { "Name": "Specialties", "Type": "Treelist", "Value": "" }, > { > "Name": "Blog Post Name", > "Type": "Single-Line Text", > "Value": "Ronald McDonald House, St. Luke’s Children’s find > new ways to help families" > }, > { "Name": "Blog Summary", "Type": "Rich Text", "Value": "" }, > { "Name": "Share Summary", "Type": "Multi-Line Text", "Value": > "" }, > { > "Name": "ShareTitle", > "Type": "Single-Line Text", > "Value": "Ronald McDonald House, St. Luke’s Children’s find > new ways to help families" > }, > { > "Name": "Blog Post Date", > "Type": "Datetime", > "Value": "2021-01-18T10:10:00Z" > }, > { > "Name": "Heading", > "Type": "Single-Line Text", > "Value": "Better Together" > }, > { "Name": "Rss Link", "Type": "General Link", "Value": "" }, > { "Name": "Providers", "Type": "Treelist", "Value": "" }, > { > "Name": "Main Blog Image Caption", > "Type": "Single-Line Text", > "Value": "" > }, > { > "Name": "Procedures and Treatments", > "Type": "Multilist", > "Value": "" > }, > { "Name": "Special Services", "Type": "Treelist", "Value": "" }, > { > "Name": "Page Title", > "Type": "Single-Line Text", > "Value": "Ronald McDonald House, St. Luke’s Children’s finding > new ways to help families" > }, > { "Name": "ShareImage", "Type": "Image", "Value": "" }, > { "Name": "Share Image", "Type": "Image", "Value": "" }, > { > "Name": "Channels", > "Type": "Multilist", > "Value": "Better Together" > }, > { "Name": "Blog Tags", "Type": "Treelist", "Value": "" }, > { > "Name": "TileHeadline", > "Type": "Single-Line Text", > "Value": "Ronald McDonald House, St. Luke’s Children’s find > new ways to help families" > }, > { "Name": "Include in Sitemap", "Type": "Checkbox", "Value": "1" > }, > { "Name": "Facilities", "Type": "Treelist", "Value": "" }, > { "Name": "TileImage", "Type": "Image", "Value": "" }, > { "Name": "Tile Category", "Type": "Droptree", "Value": "Blog > Post" }, > { > "Name": "BreadcrumbTitle", > "Type": "Single-Line Text", > "Value": "Ronald McDonald House, St. Luke’s Children’s find > new ways to help families" > }, > { > "Name": "Author", > "Type": "Droplink", > "Value": "{E9CF1FC9-EF41-4B6F-9D78-F206A5997A84}" > }, > { "Name": "Restricted To Pages", "Type": "Treelist", "Value": "" > }, > { "Name": "Meta Keywords", "Type": "Single-Line Text", "Value": > "" }, > { > "Name": "Associated Content Type", > "Type": "Droptree", > "Value": "Blog Post" > }, > { "Name": "Main Blog Image", "Type": "Image", "Value": "" }, > { "Name": "TileSummary", "Type": "Rich Text", "Value": "" }, > { > "Name": "Meta Description", > "Type": "Multi-Line Text", > "Value": "" > }, > { "Name": "Health Topics", "Type": "Multilist", "Value": "" }, > { "Name": "Icon", "Type": "Image", "Value": "" }, > { > "Name": "NavigationTitle", > "Type": "Single-Line Text", > "Value": "St. Luke’s Blogs" > }, > { > "Name": "Include in Search Index", > "Type": "Checkbox", > "Value": "1" > }, > { "Name": "Conditions", "Type": "Treelist", "Value": "" }, > { > "Name": "Heading Sub Text", > "Type": "Single-Line Text", > "Value": "Highlights from St. Luke’s and our community > partners to improve health." > }, > { > "Name": "typeaheadRollupCat", > "Type": "Single-Line Text", > "Value": "" > }, > { > "Name": "BlogPostYear", > "Type": "Single-Line Text", > "Value": "2021" > }, > { > "Name": "AuthorName", > "Type": "Single-Line Text", > "Value": "Anna Fritz" > }, > { > "Name": "BlogCategory", > "Type": "Single-Line Text", > "Value": "News and Community" > } > ], > "Modules": { > "Fields": [ > { "Name": "Content", "Type": "Rich Text", "Value": "" }, > { "Name": "Image Position", "Type": "Droptree", "Value": > "Right" }, > { "Name": "Image Source", "Type": "Image", "Value": "" }, > { > "Name": "Image Content", > "Type": "Rich Text", > "Value": "<p>For more than three decades, Ronald McDonald > House Charities of Idaho has provided housing to families with children > seeking medical care.</p>\\n<p>It also has found new ways to help during > the COVID-19 era. </p>\\n<p>When the novel coronavirus gained a foothold in > Idaho in March 2020, the organization had to put safety first and made the > tough decision to temporarily stop accepting new families not already > staying at its new Boise house. Instead, the organization paid for hotel > rooms for families it could not accommodate. </p>\\n<p>“When > everything happened, because we had to pull back services, we were trying > to look for other ways we could help families,” said Taylor Munson, > communications manager at Ronald McDonald House Charities of Idaho. > </p>\\n<p>“They are obviously already in a stressful situation with a sick > child, but the pandemic amplified that because there is even more unknown > now.”</p>\\n<p>So, how could their staff keep serving families with kids in > need? </p>\\n<p>The team at RMHCI decided to start assembling lunch boxes > filled with meals for families with kids at St. Luke’s Children’s Hospital. > </p>\\n<p>Since March, the staff has provided 4,770 meals to families at > St. Luke’s.</p>\\n<p>“The lunches provided by the Ronald McDonald House > have been a true blessing for our families in pediatrics, the pediatric ICU > and the newborn ICU,” said Sherry Iverson, director of patient and family > services at St. Luke’s Children’s.</p>\\n<p>“Being at the bedside of their > children of all ages is top priority for parents and remembering to take > care of themselves is easily forgotten. These lunches carefully assembled > by the Ronald McDonald team and then delivered to their room provide a > break, healthy food and a chance to reenergize during a very stressful > time.” </p>\\n<p>An additional 920 meals have been provided by RMHCI to > families with children receiving care at Saint Alphonsus Health System. > </p>\\n<p>The Ronald McDonald staff provides the lunch boxes four days a > week, typically including sandwiches, fruit and chips, as well as snack > bags. The total cost of the lunches so far has been about > $24,000.</p>\\n<p>“Without these wonderful care packages, many parents > would go all day without food,” Iverson said. “This partnership has been so > important during this COVID pandemic.”</p>\\n<p>Some of the food items are > donated from local organizations, while others are purchased by staff and > assembled in the kitchen at the new Ronald McDonald House facility, near > the St. Luke’s Boise Medical Center. </p>\\n<p>St. Luke’s employees pick up > the meals and take them across the street to the children’s > hospital.</p>\\n<p>“The feedback that we’ve gotten from families and nurses > and people over at St. Luke’s is that it’s so helpful because families > either may not have money to get food or they don’t want to leave their > child’s bedside,” Munson said.</p>\\n<p>The Ronald McDonald House started > accepting new families again at its facility in May 2020. St. Luke’s > Children’s Hospital is the only children’s hospital in Idaho, which has led > to a strong partnership between the medical center and nearby Ronald > McDonald House. </p>\\n<p>“It has been very collaborative with St. Luke’s. > We wanted to make sure what we were going to be doing was beneficial,” > Munson said. </p>\\n<p>The program will continue through the end of March, > marking one full year of providing meals, and then the Ronald McDonald > House staff will reevaluate for short- and long-term plans, Munson said. > </p>\\n<p>“The pandemic obviously isn’t ideal, but it did allow us find new > ways of helping families,” Munson said. “A lot of our focus is family > centered care—that’s really our goal, and feeding families is a big part of > that.”</p>\\n<p><br>\\n</p>" > }, > { > "Name": "Channel", > "Type": "Droptree", > "Value": "Better Together" > }, > { > "Name": "Heading", > "Type": "Single-Line Text", > "Value": "Better Together" > }, > { "Name": "Number to Display", "Type": "Integer", "Value": "4" > }, > { > "Name": "Related Item", > "Type": "Droptree", > "Value": "St Lukes Childrens Hospital" > }, > { > "Name": "Heading", > "Type": "Single-Line Text", > "Value": "Related Hospital" > } > ] > } > }, > "Facets": ["Blogs", "Article"], > "Title": "Ronald McDonald House, St. Luke’s Children’s find new ways > to help families", > "Summary": "" > } > } > }]' > > ________________________________ > From: Thomas Corthals <tho...@klascement.net> > Sent: Monday, October 31, 2022 8:19 PM > To: Matthew Castrigno <castr...@slhs.org> > Cc: users@solr.apache.org <users@solr.apache.org> > Subject: Re: I cannot get nested objects to index - with image links > > Hi Matthew If you set json. command=false your JSON will be treated as > custom JSON. You'll have to remove that parameter to have it treated as > Solr JSON. You can use the full command index: curl --location --request > POST ' xxxx: 8983/solr/talix/update' > ZjQcmQRYFpfptBannerStart > This Message Is From an External Sender > This message came from outside the St. Luke's email system. > > ZjQcmQRYFpfptBannerEnd > Hi Matthew > > If you set json.command=false your JSON will be treated as custom JSON. > You'll have to remove that parameter to have it treated as Solr JSON. You > can use the full command index: > > curl --location --request POST ' xxxx:8983/solr/talix/update' \ > --header 'Content-Type: application/json' \ > --data-raw ' > { > "add":{ > "doc":{ > "doc_id":"parent", > "Name":"Parent", > "child":{ > "doc_id":"child", > "Name":"Child" > } > } > } > }' > > Or you can wrap your document(s) in a JSON array: > > curl --location --request POST ' xxxx:8983/solr/talix/update' \ > --header 'Content-Type: application/json' \ > --data-raw ' > [ > { > "doc_id":"parent", > "Name":"Parent", > "child":{ > "doc_id":"child", > "Name":"Child" > } > } > ]' > > Thomas > > Op ma 31 okt. 2022 om 19:27 schreef Matthew Castrigno <castr...@slhs.org > <mailto:castr...@slhs.org>>: > Hi Thomas, > I am attempting to define my fields to accept the data that will actually > be sent, it is more deeply nested. > In doing so I have interpreted the results of the previous configuration > to not include (pseudo-)fields. In the JSON below I believe those to be > "content" from the prior example, along with "Page, Body, Modules and > Fields" but his gives me the error shown. How do I handle these other > fields. Thank you for your assistance, it is greatly appreciated. > > > <field name="partner" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="command" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="doc_id" type="string" indexed="true" stored="true" > required="true" multiValued="false" /> > <!-- > <field name="content" type="string" indexed="true" stored="true" > required="true" multiValued="false" /> > --> > <field name="Id" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="Name" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="Url" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="Date" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="ContentType" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="Facets" type="strings" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="Title" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="Summary" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > > <field name="Type" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > <field name="Value" type="string" indexed="true" stored="true" > required="false" multiValued="false" /> > > <!-- docValues are enabled by default for long type so we don't need > to index the version field --> > <field name="_version_" type="plong" indexed="false" stored="false"/> > > <!-- 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="false" > docValues="false" /> > <!-- for nested documents (relationship tracking) --> > <field name="_nest_path_" type="_nest_path_" /><fieldType > name="_nest_path_" class="solr.NestPathField" /> > > <field name="_text_" type="text_general" indexed="true" stored="false" > multiValued="true"/> > > curl --location --request POST ' > http://localhost:8983/solr/talix/update?json.command=false [localhost]< > https://urldefense.com/v3/__http://localhost:8983/solr/talix/update?json.command=false__;!!FkC3_z_N!LgZrR73cMpi5QtTn3HlQ8otfmdBkgNRfgjpr8LnJU_doX019ya3vSxF9z6Ha9TUXIGqfIpGDCvxnCZf0$>' > \ > --header 'Content-Type: application/json' \ > --data-raw '{ > "partner": "88027688-62c4-459a-b4d5-a8ecf9edd1bf", > "command": "add", > "doc_id": "2ff99d1a-a21b-4391-9c47-af2865acb753", > "content": { > "Page": { > "Id": "2ff99d1a-a21b-4391-9c47-af2865acb753", > "Name": "Ronald McDonald House Idaho meals", > "Url": > "/blogs/st-lukes/news-and-community/2021/jan/ronald-mcdonald-house-idaho-meals", > "Date": "2022-10-03T12:30:17.3388537", > "ContentType": "Blog", > "Body": { > "Fields": [ > { "Name": "Heading Background Image", "Type": "Image", "Value": > "" }, > { "Name": "Tile Wide Image", "Type": "Image", "Value": "" }, > { "Name": "Specialties", "Type": "Treelist", "Value": "" }, > { > "Name": "Blog Post Name", > "Type": "Single-Line Text", > "Value": "Ronald McDonald House, St. Luke’s Children’s find > new ways to help families" > }, > { "Name": "Blog Summary", "Type": "Rich Text", "Value": "" }, > { "Name": "Share Summary", "Type": "Multi-Line Text", "Value": > "" } > ], > "Modules": { > "Fields": [ > { "Name": "Content", "Type": "Rich Text", "Value": "" }, > { "Name": "Image Position", "Type": "Droptree", "Value": > "Right" }, > { "Name": "Image Source", "Type": "Image", "Value": "" }, > { > "Name": "Image Content", > "Type": "Rich Text", > "Value": "<p>For more than three decades</p>" > } > ] > } > }, > "Facets": ["Blogs", "Article"], > "Title": "Ronald McDonald House, St. Luke’s Children’s find new ways > to help families", > "Summary": "" > } > } > }' > > Response: > { > "responseHeader":{ > "status":400, > "QTime":0}, > "error":{ > "metadata":[ > "error-class","org.apache.solr.common.SolrException", > "root-error-class","org.apache.solr.common.SolrException"], > "msg":"undefined field: \"content.Page.Id [content.page.id]< > https://urldefense.com/v3/__http://content.Page.Id__;!!FkC3_z_N!LgZrR73cMpi5QtTn3HlQ8otfmdBkgNRfgjpr8LnJU_doX019ya3vSxF9z6Ha9TUXIGqfIpGDCrcqIV9e$ > >\"", > "code":400}} > ________________________________ > From: Matthew Castrigno <castr...@slhs.org<mailto:castr...@slhs.org>> > Sent: Thursday, October 27, 2022 10:36 AM > To: Thomas Corthals <tho...@klascement.net<mailto:tho...@klascement.net>> > Cc: users@solr.apache.org<mailto:users@solr.apache.org> < > users@solr.apache.org<mailto:users@solr.apache.org>> > Subject: Re: I cannot get nested objects to index - with image links > > Thank you, Thomas! Changing the required to false allowed the document to > be indexed. I did not gleam this information from the SOLR documentation > regarding nested documents. Do you know of any good sources for educational > material on this subject? I cannot change the payloads that I am working > with unfortunately. They make heavy use of deeply nested json object. Thank > you again for your assistance, it is most appreciated! > ________________________________ > From: Thomas Corthals <tho...@klascement.net<mailto:tho...@klascement.net > >> > Sent: Thursday, October 27, 2022 1:34 AM > To: Matthew Castrigno <castr...@slhs.org<mailto:castr...@slhs.org>> > Cc: users@solr.apache.org<mailto:users@solr.apache.org> < > users@solr.apache.org<mailto:users@solr.apache.org>> > Subject: Re: I cannot get nested objects to index - with image links > > Hi Matthew All the fields in your schema are required="true". This means > they are required for all documents, whether parents or children (or > standalone). "Required" fields (from a business logic perspective) on > parents > ZjQcmQRYFpfptBannerStart > This Message Is From an Untrusted Sender > You have not previously corresponded with this sender. > > ZjQcmQRYFpfptBannerEnd > Hi Matthew > > All the fields in your schema are required="true". This means they are > required for all documents, whether parents or children (or standalone). > "Required" fields (from a business logic perspective) on parents and > children will usually be different and that can't be enforced in a Solr > schema. > > The only fields that can be required="true" are the ones that are required > for all types of documents. The uniqueKeyField is definitely one of them. > For all other fields, it might make more sense to handle this constraint in > your application. > > Thomas > > Op do 27 okt. 2022 om 01:08 schreef Matthew Castrigno <castr...@slhs.org > <mailto:castr...@slhs.org>>: > Thank you so much for your response, Thomas, I do appreciate it. > I made the changes, but I am getting a different error now. Did I not > interpret your instructions correctly? > https://i.postimg.cc/SNM4t7vs/updated-schema.png [i.postimg.cc]< > https://urldefense.com/v3/__https://i.postimg.cc/SNM4t7vs/updated-schema.png__;!!FkC3_z_N!JJcOTo8MLWYS72yOLdGmPbY8vOwX_B_w1HO2eCNy2NK_4nSWBTu3eKknYiA8rgpJ4E66YWvLPJeAa1Gl$ > > > > https://i.postimg.cc/RZtcF8bB/Screenshot-2022-10-26-170222.png [ > i.postimg.cc]< > https://urldefense.com/v3/__https://i.postimg.cc/RZtcF8bB/Screenshot-2022-10-26-170222.png__;!!FkC3_z_N!JJcOTo8MLWYS72yOLdGmPbY8vOwX_B_w1HO2eCNy2NK_4nSWBTu3eKknYiA8rgpJ4E66YWvLPNYoRUGC$ > > > > ________________________________ > From: Thomas Corthals <tho...@klascement.net<mailto:tho...@klascement.net > >> > Sent: Tuesday, October 25, 2022 1:28 AM > To: users@solr.apache.org<mailto:users@solr.apache.org> < > users@solr.apache.org<mailto:users@solr.apache.org>> > Subject: Re: I cannot get nested objects to index - with image links > > Hi Matthew The (pseudo-)field in which you want to put the nested > documents ("content" in your example) should not be added to the schema. > The actual fields of the nested document (id, stuff1, stuff2) need to match > an explicit field definition > ZjQcmQRYFpfptBannerStart > This Message Is From an Untrusted Sender > You have not previously corresponded with this sender. > > ZjQcmQRYFpfptBannerEnd > > Hi Matthew > > The (pseudo-)field in which you want to put the nested documents ("content" > in your example) should not be added to the schema. The actual fields of > the nested document (id, stuff1, stuff2) need to match an explicit field > definition or a dynamicField definition in your schema though. > > Thomas > > Op ma 24 okt. 2022 om 23:48 schreef Matthew Castrigno <castr...@slhs.org > <mailto:castr...@slhs.org>>: > > > Hello Community, Thank you for taking the time to read my message. > > > > I am attempting to index (update) a document with a nested object. > > > > In reading the documentation is seems to state that the fields of the > > nested object do not need to be and should not be added > > > > to schema.xml. I am getting error that the field of the nested object is > > undefined, and I am not sure what I am doing wrong. > > > > Any insights appreciated. Thank you > > > > > https://urldefense.com/v3/__https://i.postimg.cc/25GtB1Mc/update.png__;!!FkC3_z_N!MH9mbztbPvc05Og3x_fcnapmPzux7fhqgdChsAIR0bqiTiV_-BVnIdI8Z---HIWeD5TLbiwytoGIDSsB$ > > > > > https://urldefense.com/v3/__https://i.postimg.cc/SKk5s6TY/schema.png__;!!FkC3_z_N!MH9mbztbPvc05Og3x_fcnapmPzux7fhqgdChsAIR0bqiTiV_-BVnIdI8Z---HIWeD5TLbiwytlHh85s3$ > > > > ---------------------------------------------------------------------- > > "This message is intended for the use of the person or entity to which it > > is addressed and may contain information that is confidential or > > privileged, the disclosure of which is governed by applicable law. If the > > reader of this message is not the intended recipient, you are hereby > > notified that any dissemination, distribution, or copying of this > > information is strictly prohibited. If you have received this message by > > error, please notify us immediately and destroy the related message." > > > > > ________________________________ > "This message is intended for the use of the person or entity to which it > is addressed and may contain information that is confidential or > privileged, the disclosure of which is governed by applicable law. If the > reader of this message is not the intended recipient, you are hereby > notified that any dissemination, distribution, or copying of this > information is strictly prohibited. If you have received this message by > error, please notify us immediately and destroy the related message." > ________________________________ > "This message is intended for the use of the person or entity to which it > is addressed and may contain information that is confidential or > privileged, the disclosure of which is governed by applicable law. If the > reader of this message is not the intended recipient, you are hereby > notified that any dissemination, distribution, or copying of this > information is strictly prohibited. If you have received this message by > error, please notify us immediately and destroy the related message." > > ---------------------------------------------------------------------- > "This message is intended for the use of the person or entity to which it > is addressed and may contain information that is confidential or > privileged, the disclosure of which is governed by applicable law. If the > reader of this message is not the intended recipient, you are hereby > notified that any dissemination, distribution, or copying of this > information is strictly prohibited. If you have received this message by > error, please notify us immediately and destroy the related message." >