Search code examples
solrsolr4solrcloud

Solr : Importing data with single SP call



I have one solr collection called document.
In that there are fields like

id,name,associated_folder,is_associate & other

The field is_associate depends on associated_folder.

I am importing data using Data Import provided in Solr Dashboard
My problem is that Stored Procudeure which returns data like :

#   id      name        associated_folder   is_associate
1   DOC1    DOCNAME     1001,1002,1003      true
2   DOC2    DOCNAME     4001,4002,4003      true
3   DOC3    DOCNAME     -1                  false

& in my schema file associated_folder declare like :

<field name="associated_folder" type="int" indexed="true" stored="true" multiValued="true" omitNorms="true" termVectors="false" termPositions="false"  termOffsets="false" default="-1"/>

field type is int for associated_folder & SP returns the comma separated String value for associated folder id & it is better for me to make one SP call & set information for Document as performance concern.

I don't want to make extra stored procedure call for get associated_folder/is_associate

Is there any way using which I can import all fields using single SP with existing schema ?

Thanks for looking here..!


Solution

  • In your import configuration for the Data Import Handler, you can add transformer="RegexTransformer" to your <entity> definition, and then use splitBy="," on the field to split it into multiple values.

    <entity name="foo" transformer="RegexTransformer" .... >
        ...
        <field column="associated_folder" splitBy="," />
    </entity>
    

    See the documentation for RegexTransformer.