0

I would like to create an index from my database data. Currently I use a SQL view for extract the data from the base. In my results I have an unique ID per result and each result can contains several possible another ids for one of the column that I need to search.

For example from one store I have 3 columns : ID, NAME, PRODUCTS_ID. PRODUCTS_ID has possibly several values per store. How I can index into SOLR such document. Must I create one document per products_id (and after that I need to make in someway distinct of the results) or I can use another way to present this results ? I saw that there is multiValued configuration, but is there a best way to done ?

Vicking
  • 27
  • 6

2 Answers2

1

1) In the schema.xml your filed must be mulitvalued. Example

<field name="specialDeliveryTimes" type="int" stored="true" indexed="true" multiValued="true"/>

2) In the SQL statement to must join the values with , Example using Oracle:

LISTAGG(AOP_LOCATIONID, ',') WITHIN GROUP (ORDER BY AOP_LOCATIONID) AS SPECIALDELIVERYTIMES
Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82
0

Here the implementation of the solution proposed By Simas_ch.

In db-data-config.xml define:

<dataConfig>
   <dataSource name="jdbc" driver="***" 
      url="jdbc:****" 
      user="***" password="***"/>
   <document>
    <entity name="operation" transformer="RegexTransformer"
        pk="ID"
        query="SELECT * FROM GRC.V_SOLR_REGISTRAR_FR_CATALOG@GRCLINK" 
    >
       <field column="fieldDB" splitBy="," sourceColName="fieldSolr"/>

It is important to put transformer="RegexTransformer" and splitBy="," sourceColName="TOP_SERVICE_ID".

After in schema.xml define as describe previosly the field :

<field name="fieldSolr" type="int" indexed="true" stored="true" multiValued="true"/>

Where multiValued is important.

And in the SQL query make a concatenation :

LISTAGG(test, ',') WITHIN GROUP (ORDER BY test) AS fieldDB
Vicking
  • 27
  • 6