0

Is it possible to create a nested data structure in Solr using the content search index configurations? I'm curious if I can create a document like the following, then query against and/or facet the fields in the nested structure.

{   
    "_group":"fe58033195a142f7b33331d85e6120a9"
    "school_name_s": "School 1"
    "programs": [
        {
            "program_name_s":"Program 1",
            "program_type_s":"Program Type 1"
        },
        {
            "program_name_s":"Program 2",
            "program_type_s":"Program Type 1"
        },
        {
            "program_name_s":"Program 3",
            "program_type_s":"Program Type 2"
        }
    ]                
}

I'm currently using Sitecore 10.1.0 and Solr 8.4.0

2
  • Can you provide an example of how your content currently looks in the index? Commented May 4, 2022 at 23:10
  • It looks like the example above (which has been simplified down), but without the nested programs field.
    – Jay
    Commented May 5, 2022 at 15:34

1 Answer 1

1

Short Answer

No. You cannot create nested documents within Solr using the default Sitecore indexing functionality.

Since there's not a lot of background on the goals that you are trying to achieve, I can share some options that are available; each with their own benefits and drawbacks. It'll be up to you to decide whether to implement any of these suggestions.

Option 1:

Use GraphQL (comes with Headless Services 16+) to query your parent and child documents together.

Option 2:

Create an index re-crawler that builds a new index using the nested document functionality. There's documentation on how to do this in Solr here:

https://solr.apache.org/guide/8_4/indexing-nested-documents.html

This option does give you the ability to use BlockJoin faceting to search your documents and child documents.

https://solr.apache.org/guide/8_4/blockjoin-faceting.html

I've done this in the past, but some thorough consideration needs to be given to an update strategy on the new index.

WARNING: With the exception of in-place updates, the whole block must be updated or deleted together, not separately. For some applications this may result in tons of extra indexing and thus may be a deal-breaker.

Option 3:

Use a computed field to store your child documents as json within a string field. This is quick and dirty and will get your content into the index, but you can't do any filtering, faceting or block joins on this field.

1
  • Thank you for your detailed and thoughtful response Chet!
    – Jay
    Commented May 6, 2022 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.