Solr DataImportHandler cache with multiple keys

58 Views Asked by At

I'm trying to index data from a database using the Solr DataImportHandler. The database contains products defined by a class and with multiple features with the following relevant tables:

  • product table contains a PK product_id and a FK class_id
  • product_feature table contains a PK (product_id & feature_id)
  • class_feature table contains a PK (class_id & feature_id)

For each product I need to index multiple product_feature and for each of those I need to index multiple class_feature. I also need to cache sub-entities for improved performance. The entity-definitions in the config look like this:

<entity name="product" query="select product_id, class_id, ... from product">
  ...
  <entity name="product_feature" query="select product_id, feature_id, ... from product_feature"
      cacheImpl="SortedMapBackedCache" cacheKey="product_id" cacheLookup="product.product_id">
    ...
    <entity name="class_feature" query="select class_id, feature_id, ... from class"
        cacheImpl="SortedMapBackedCache" where="class_id=product.class_id AND feature_id=product_feature.feature_id">
      ...
    </entity>
  </entity>
</entity>

Notice in the innermost entity class_feature, I'm defining a where attribute matching two FKs, one on the outermost product and another on the direct parent product_feature. This doesn't seem to work. How must I define an entity cache to match on multiple keys?

0

There are 0 best solutions below