The API Manager has Apache Solr based indexing for API documentation content. It provides both the API Publisher and Store full-text search facility to search through API documentation, find documents and related APIs. The search syntax is doc:keyword. Search criteria looks for the keyword in any word/phrase in the documentation content and returns both the matching documents and associated APIs.
Configuring the index
The following media types have Apache Solr based indexers by default, configured using the
<Indexers> element in
- Text : text/plain
- PDF : application/pdf
- MS word : application/msword
- MS Powerpoint : application/vnd.ms-powerpoint
- MS Excel : application/vnd.ms-excel
- XML : application/xml
In addition to the default ones, you can write your own indexer implementation and register it. When a new resource is added to the registry with the relevant media type in an indexer, the content is indexed using that. Given below is a sample indexer code:
Writing custom indexer
Sample Indexer Code. (Refer complete source sample-indexer.zip)
1. You can write the custom indexer and include the relevant jar file to APIM_HOME/repository/components/lib directory.
2. Then add the new indexer to APIM_HOME/repository/conf/registry.xml under <Indexers>
<indexer class="org.wso2.indexing.sample.PlainTextIndexer" mediaTypeRegEx="text/plain" profiles ="default,api-store,api-publisher"/>
indexer class name
A regex pattern to match media type
APIM profiles in which indexer should be available
3. restart the server
4. Now if you add an API documentation from the newly added media type, it will be indexed and you will be able to search for content using ‘doc’ search term.