lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandre Rafalovitch <>
Subject Re: Creating a SolrJ Data Service to send JSON to Solr
Date Tue, 16 Aug 2016 23:42:28 GMT
Why do you need a POJO? For Solr purposes, you could just get the
field names from schema and use those to map directly from JSON to the
'addField' calls in SolrDocument.

Do you need it for non-Solr purposes? Then you can search for generic
Java dynamic POJO generation solution.

Also, you could look at creating a superset rather than common-subset
POJO and then ignore all unknown fields on Solr side by adding a
dynamicField that matches '*' with everything (index, store,
docValues) set to false.


Newsletter and resources for Solr beginners and intermediates:

On 17 August 2016 at 02:49, Jennifer Coston
<> wrote:
> Hello,
> I am trying to write a data service using SolrJ that will allow me to
> accept JSON through a REST API, create a Solr document ,and write it to
> multiple different Solr cores (depending on the core name specified). The
> problem I am running into is that each core is going to have a different
> schema. My current code has the common fields between all the schemas in a
> data POJO which I then walk and set the values specified in the JSON to the
> Solr Document. However, I don’t want to create a different class for each
> schema to process the JSON and convert it to a Solr Document. Is there a
> way to process the extra JSON fields that are not common between the
> schemas and add them to the Solr Document, without knowing what they are
> ahead of time? Is there a way to convert JSON to a Solr Document without
> having to use a POJO?  An alternative I was looking into is to use the
> SolrClient to get the schema fields, create a POJO, walk that POJO to
> create a Solr Document and then add it to Solr but, it doesn’t seem to be
> possible to obtain the fields this way.
> I know that the easiest way to add JSON to Solr would be to use a curl
> command and send the JSON directly to Solr but this doesn’t match our
> requirements, so I need to figure out a way to perform the same operation
> using SolrJ. Any other ideas or suggestions would be greatly appreciated!
> Thank you,
> -Jennifer

View raw message