One-to-many mapping in SOLR

I am trying to map multiple objects from an existing database to SOLR.

Tables:

Hotel: hotel_id hotel_name

HotelToCategory: hotel_id category_id Speed

Category: category_id name Value

How can I use DataImportHandler to create such documents:

{ hotel_name: 'name', hotel_id: 1, categories: [ { category_name: 'cname', value: 'val', rate: 3, } ] } 

Any help would be greatly appreciated!

+6
lucene solr
source share
1 answer

Relations are indexed using multi-level objects in DIH. Check out the DIH page on the Solr wiki page.

There are also some basic examples of this included in Solr distributions in the DIH examples / examples.

There is a limitation here, although solr does not (currently) support the relationship between index documents, so you have to find a workaround to index this. For example, simply storing the displayed data in a non-indexed field (which may require very frequent reindexing):

 <document> <entity name="hotel" query="select * from hotel"> <field column="id" name="hotel_id" /> <field column="hotel_name" name="hotel_name" /> <entity name="hotel_category_display" query="SELECT STATEMENT THAT RETURNS JSON REPRESENTATION"> <field column="category" name="category" /> </entity> </document> 

Or, saving only the category identifier and search (either by the database, or by individual index categories, and by searching in Solr):

 <entity name="hotel_category_display" query="SELECT STATEMENT THAT RETURNS JSON REPRESENTATION"> <field column="category" name="category" /> </entity> 
+6
source share

All Articles