Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:38:17+00:00 2026-06-07T23:38:17+00:00

What would be a good design for using Solr to search in complex JSON?

  • 0

What would be a good design for using Solr to search in complex JSON? For instance there could be a document like:

{
    "books" : [
        {
            "title" : "Some title",
            "author" : "Some author",
            "genres" : [
                "thriller",
                "drama"
             ]
        },
        {
            "title" : "Some other title",
            "author" : "Some author",
            "genres" : [
                "comedy",
                "nonfiction",
                "thriller"
             ]
         }
    ]
 }

A sample query would be to get all documents that have a book whose author is “Some author” and one of the book’s genres is “drama”.

Right now the design I came up with is to have a dynamicField in the schema.xml that indexes everything as text (for now), like so:

 <dynamicField name="*" type="text" index="true" stored="true"/>

Then SolrJ is used to parse the JSON and create a SolrInputDocument with fields for each piece of data. For instance these are the field/values that would be created for the example JSON above:

books0.title : "Some title"
books0.author : "Some author"
books0.genres0 : "thriller"
books0.genres1 : "drama"
books1.title : "Some other title"
books1.author : "Some author"
books1.genres0 : "comedy"
books1.genres1 : "nonfiction"
books1.genres2 : "thriller"

At this point we could use the LukeRequestHandler to get all the fields in the index, and then make a big Solr query that checks all the fields we are interested in. For the sample query above the query would check all “books#.author” and “books#.genres#” fields. This solution seems inelegant and the queries could get very big if there are a lot of fields.

Being able to use wildcards in field names would be useful, but I don’t think that is possible with Solr.

Is there a better way to accomplish this, possibly by using some clever combination of “copyField” and “multiValued” in the schema?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:38:19+00:00Added an answer on June 7, 2026 at 11:38 pm

    You can index the book entity as documents.

    <field name="id" type="string" indexed="true" stored="true" required="true" />  
    <field name="title" type="text_general" indexed="true" stored="true"/>   
    <!-- Don't perform stemming on authors - You can use field with lower case, ascii folding for analysis -->   
    <field name="authors" type="string" indexed="true" stored="true" multiValued="true"/>  
    <field name="genre" type="string" indexed="true" stored="true" multiValued="true"/>  
    

    Use Dismax parser to search upon authors and genre.
    Match on these field should return you back the document.
    You can use genre for filtering with filter query as well e.g. fq=genre:drama

    If you want search behavior different for fields you can simply use copyField to copy the fields and have a different analysis performed on them.
    e.g.

    <field name="genre_search" type="text_general" indexed="true" stored="true" multiValued="true"/>
    
    <copyField source="genre" dest="genre_search"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would using MVC to write a serious game be good design and a smart
I would like to design an application that consists of an application server. There
I would like to know if the following code would be a good pattern
I am building a Windows form application using .NET 3.5. I would like to
What is a good design for caching the results of an expensive search in
What would be a good design pattern if I require to test a C++
I'd like suggestions for the design of a CRUD business app using Silverlight 4,
I need some opinions on what would be a good approch for using XML
We need some input on what is a good design pattern on using AJAX
I've decided that it would be good for me to move outside of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.