Search code examples
javatomcatsolrnosqlsearch-engine

how to store in SOLR (mini) relational data


My data set is title, description and tags.
I would like to store and index in the SOLR the tag_name and their relative tag_id.
As can be understood, each record has one title, one description bt many tag names + tag ids.

I guess I can store the tags as "some-tag-[id]" but his seems wrong.


Solution

  • You can index tags and tags_id as multivalued fields and add in order.
    The order is maintained so you can map them within the fields.

    <field name="tags" type="string" indexed="true" stored="true" multiValued="true"/>
    <field name="tags_id" type="string" indexed="false" stored="true" multiValued="true"/>
    

    Response -

    <arr name="tags">
        <str>tag1</str>
        <str>tag2</str>
        <str>tag3</str>
    </arr>
    <arr name="tags_id">
        <str>id1</str>
        <str>id2</str>
        <str>id3</str>
    </arr>