Create Our Own custom indexer for Wso2 registry indexing
In Wso2 registry, we are using apache solr to support registry search feature. To support solr search, all registry resources which are saved in RDBMS, are indexed using periodic task.
In order to index the resource content, we need to extract the content of the resource. Extracting content of the resource logic varies from resource type. So they have given an extension point to write our own custom logic to create index document of each resource. Steps to create custom indexer are as follows,
- Create maven project and add following dependencies and wso2 maven repository
- Create a java class implementing indexer interface (org.wso2.carbon.registry.indexing.indexer.Indexer) and override the method getIndexedDocument(). Resource content extracting logic should write here. For example,
- Add build jar file into <carbon-home>/repository/components/dropins
- Add below configure inside <indexingConfiguration>/<indexers> in registry.xml. (inside <carbon-home>/repository/conf/)
<indexer class=”org.wso2.carbon.registry.indexer.TextIndexer” mediaTypeRegEx=”application/text\+plain” profiles=”default,uddi-registry”/>
So that it looks like,
- Start the server, newly added indexer will hit when we add/update resource with the mediatype mapped for the indexer in registry.xml
Happy Searching !!!!!!!!!!!