The first link shows how to create children with specific content, but you need to use "_childDocuments_":... explicitly instead of the "prices: " and perhaps add "type: price" or some such to differentiate record types.
But I am not quite following why you say it will increase 50 times. By comparison to what? How did you want the children documents to be stored/found (in Elasticsearch or Solr)? One way to think through this problem is to be explicit about what the _search_ would look like and then adjust indexing accordingly. Regards, Alex. Personal: http://www.outerthoughts.com/ and @arafalov Solr resources and newsletter: http://www.solr-start.com/ and @solrstart Solr popularizers community: https://www.linkedin.com/groups?gid=6713853 On 15 November 2014 18:24, David Lee <seek...@gmail.com> wrote: > Thanks Alex. I take a look at the approach of transforming JSON document > before mapping it to the Solr schema at > http://lucidworks.com/blog/indexing-custom-json-data/ . > > It's a walk-around. But in my case, if every state has its own price, > the number of documents needs to be indexed will increase 50 times, which > may have negative impact on performance,etc. > > {prices:[{state:"CA", price:"101.0"}, {state:"NJ", > price:"102.0"},{state:"CO", price:"102.0"}]} > > Is there any other better solution? > > Thanks, > DL > > On Sat, Nov 15, 2014 at 2:17 PM, Alexandre Rafalovitch <arafa...@gmail.com> > wrote: > >> It's simple in Elasticsearch, but what you actually get is a single >> document and all it's children data ({state, price}) entries are >> joined together behind the scenes into the multivalued fields. Which >> may or may not be an issue for you. >> >> For Solr, nested documents need to be parent/child separate documents. >> And the syntax is a bit more explicit. So, you can either provide more >> explicit JSON: >> >> https://cwiki.apache.org/confluence/display/solr/Uploading+Data+with+Index+Handlers#UploadingDatawithIndexHandlers-NestedChildDocuments >> >> or transform JSON document before mapping it to the Solr schema: >> http://lucidworks.com/blog/indexing-custom-json-data/ (latest 4.10 Solr). >> >> Regards, >> Alex. >> Personal: http://www.outerthoughts.com/ and @arafalov >> Solr resources and newsletter: http://www.solr-start.com/ and @solrstart >> Solr popularizers community: https://www.linkedin.com/groups?gid=6713853 >> >> >> On 15 November 2014 17:05, David Lee <seek...@gmail.com> wrote: >> > Hi All, >> > >> > How do I index complex JSON data in SOLR? For example, >> > >> > {prices:[{state:"CA", price:"101.0"}, {state:"NJ", >> > price:"102.0"},{state:"CO", price:"102.0"}]} >> > >> > >> > It's simple in ElasticSearch, but in SOLR it always reports the following >> > error: >> > "Error parsing JSON field value. Unexpected OBJECT_START" >> > >> > >> > Thanks, >> > DL >> > > > > -- > SeekWWW: the Search Engine of Choice > www.seekwww.com