: So if we are to support atomic update on a leader ID, then the atomic 
: update logic would need to fetch also all children and reconstruct the 
: entire block before committing.
: 
: From your experience it obviously does not, so I assume it is a corner 

The type of reconstruction Jan is describing does in fact exist in SOlr, 
and has for some time -- but it only works if you use the recommended 
"psuedo-fields" form of nested documents...

https://solr.apache.org/guide/solr/latest/indexing-guide/indexing-nested-documents.html#example-indexing-syntax

...which causes the nested documents need to be associated with a 
psuedo-field name in the parent doc, which identifies the "type" of the 
nested document.

This indexing approach allows Solr (via the recommended default schema & 
update processor chain) to track the hierarchical relationships of the 
nested documents (at arbitrary depth) via the _root_, _nest_path_, and 
_nest_parent_ fields so that atomic updates can reconstruct the original 
hierarchy.

Dario's linked gist uses the legacy "anonymous children" approach which 
is not recommended but still supported...

https://solr.apache.org/guide/solr/latest/indexing-guide/indexing-nested-documents.html#indexing-anonymous-children

Dario: click the "SolrJ" tab above each example in the two sections i 
linked above to see the difference in how you would change your java code 
to do this...



$ curl -sS --globoff 
'http://localhost:8983/solr/demo/select?q=id:P22!prod&fl=*,[child]'
{
  "responseHeader":{
    "status":0,
    "QTime":3,
    "params":{
      "q":"id:P22!prod",
      "fl":"*,[child]"
    }
  },
  "response":{
    "numFound":1,
    "start":0,
    "numFoundExact":true,
    "docs":[{
      "id":"P22!prod",
      "name_s":"Mont Blanc Fountain Pen",
      "description_t":"A Premium Writing Instrument ...",
      "_version_":1873449236368982016,
      "_root_":"P22!prod",
      "skus":[
        {
          "id":"P22!S22",
          "color_s":"RED",
          "price_i":89,
          "_version_":1873449236368982016,
...
$ curl -sX POST 'http://localhost:8983/solr/demo/update/json?commit=true' 
--data-binary '[{"id":"P22!prod","name_s":{"set":"Awesome Pen"}}]'
{
  "responseHeader":{
    "status":0,
    "QTime":52
  }
}
$ curl -sS -globoff 
'http://localhost:8983/solr/demo/select?q=id:P22!prod&fl=*,[child]''
{
  "responseHeader":{
    "status":0,
    "QTime":1,
    "params":{
      "q":"id:P22!prod",
      "fl":"*,[child]"
    }
  },
  "response":{
    "numFound":1,
    "start":0,
    "numFoundExact":true,
    "docs":[{
      "id":"P22!prod",
      "name_s":"Awesome Pen",
      "description_t":"A Premium Writing Instrument ...",
      "_version_":1873449315287957504,
      "_root_":"P22!prod",
      "skus":[
        {
          "id":"P22!S22",
          "color_s":"RED",
          "price_i":89,
          "_version_":1873449315287957504,
...





-Hoss
http://www.lucidworks.com/

Reply via email to