You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Rick Leir <ri...@canadiana.ca> on 2015/12/14 17:12:12 UTC
re: nested fields
On Sun, Dec 13, 2015 at 8:26 PM, <so...@lucene.apache.org>
wrote:
>
> I want to define nested fileds in SOLR using schema.xml.
Us too (using Solr 5.3.1). And doco is not jumping out at me. My approach
is (please suggest a better way)
1/ create a blank core
2/ add a few nested docs using bin/post
3/ use the schema browser to see what fields got added
http://localhost:8983/solr/#/dorsetdata/schema-browser
4/ add those fields to a schema.xml
Here is an experimental nested doc, which results in 3 'flat' Solr docs:
[
{
"id" : "552",
"key" : "552",
"pkey": "552",
"type_s": "book",
"lang": "Eng",
"media" : "text",
"canonicalMaster": "tdr/552",
"title": "The object, benefits and history of",
"publisher": "[Halifax, N.S.? : s.n.], 1855 (Halifax, N.S. : J.
)",
"content_type" : "parentDocument",
"_childDocuments_" : [
{
"id" : "552.8",
"key" : "oocihm.552.8",
"pkey": "oocihm.552",
"type_s": "page",
"label": "Image 8",
"seq" : "8",
"canonicalMaster": "tdr/552/data/files/0008.jpg",
"canonicalMasterMime": "image/jpeg",
"text": "DBJE 11 OF NORMAL SCHOOLS. 3 illustration as a
whole of what such"
},
{
"id" : "552.9",
"key" : "oocihm.552.9",
"pkey": "oocihm.552",
"type_s": "page",
"label": "Image 9",
"seq" : "9",
"canonicalMaster": "tdr/552/data/files/0009.jpg",
"canonicalMasterMime": "image/jpeg",
"text": "BESEFITS OF NORMAL SCHOOLS. with a natural
titncss. both "
}
]
}
]
Then a search for normal:
$ curl http://localhost:8983/solr/dorsetdata2/query -d '
q={!parent which="content_type:parentDocument" score=total}
type_s:page AND normal&
wt=json&
omitHeader=true&
indent=false&
fl=score,[child parentFilter=type_s:book childFilter=normal ],title,publisher'
Look for ChildDocTransformerFactory in
https://cwiki.apache.org/confluence/display/solr/Transforming+Result+Documents
cheers - Rick