tigger tigger
tigger tigger

Reputation: 109

Using Solr to search multiple database tables

I have about 40 tables in database and we are planning to use Solr to search. So, when users enter a search they can choose some or all tables to search for data. These 40 tables are not related to each other. I tried search on single table and it worked great but I am not clear on how to approach the above scenario in Solr. Any ideas are greatly appreciated.

Upvotes: 0

Views: 2133

Answers (2)

LaChRiZ
LaChRiZ

Reputation: 39

You forgot to explain how to store the table name into the created "table"-field.

This is, what I was looking for:

TemplateTransformer: Can be used to overwrite or modify any existing Solr field ... The value assigned to the field is based on a static template string ... Solr Wiki

data-config.xml:

<entity name="Books" transformer="TemplateTransformer">
  <!-- other fields -->
  <field column="Table" template="Books"/>
</entity>

<entity name="Movies" transformer="TemplateTransformer">
  <!-- other fields -->
  <field column="Table" template="Movies"/>
</entity>

schema.xml:

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

Upvotes: 1

Edgar Klerks
Edgar Klerks

Reputation: 1537

You can add the table name to the solr schema.

For example add a field table:

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

Now you can choose to facet on tables:

&fq=table:(users OR log)

You need to make the value stored, to know from which table something comes and decide your process strategy for the results.

I think this is a reasonable approach.

Upvotes: 1

Related Questions