Howto: Reload entities in solr

99 Views Asked by At

Lets say you have a Solr core with multiple entities in your document. In my case the reason for that is that the index is fed by SQL queries and I don't want to deal with multiple cores. So, in case you add or change one entity configuration, you eventually have to re-index the whole shop, which can be time consuming.

There is a way, to delete and re-index one single entity, and this is how it works: Prerequisite: your index entries have to have a field, which reflects the entity name. You could either do that via a constant in your SQL statement or by using the TemplateTransformer:

<field column="entityName" name="entityName" template="yourNameForTheEntity"/>

You can use this name to remove all entity items from the index via using the Solr admin UI. Go to documents,

  • request-Handler: /update
  • Document-Type: JSON
  • Document(s): delete: {query:{entityName:yourNameForTheEntity}}

After submitting the document, all related items are gone and you can see that via running a query on the query page: {!term f=entityName}yourNameForTheEntity

Then go to the Dataimport page to re-load you entity. Uncheck the Clean checkbox, select your entity and Execute.

After the indexing is complete, you can go back to the query page and check the result.

That's it.

Have fun, Christian

0

There are 0 best solutions below