From OpenCms Wiki
Jump to: navigation, search

Adding a search index

OpenCms comes with a built in search index for the online and offline projects. Since version 7, additional search indices can be created in the administration view. In former versions this had to be done through editing the XML config file opencms-search.xml. (Make a backup before touching these config files!!! OpenCms will not even run if there is a problem in them.)

A additional search index section would go in the indexes section of opencms-search.xml, and would look something like this:


You also need to create an index source to go along with it, it goes in the indexsources section of the XML:

    <indexer class=""/>

Adding custom document types

Since OpenCms 7 you can add standard document types to your search index in the administration view. The standard types are as follows:

  • generic (
  • html (
  • image (
  • msexcel (
  • mspowerpoint (
  • msword (
  • pdf (
  • rtf (
  • text (
  • xmlcontent (
  • xmlpage (

And if you want to add a custom document type, you'll have to add this to the documenttypes section of the opencms-system.xml at first. You may also have to create a CmsDocumentClass in Java for it, or find one it can share. See Custom_File_and_Folder_Types for more information on how to create a custom document type. Here is an existing sample:


If you lets say have an xmlcontent news module with the resource and document type news, and you want to add this to your index you have to edit the opencms-search.xml as follows:

go to the


-section, copy an existing


-node (in this case it is best to take the xmlcontent documenttype-node) and modify it to fit your needs. Enter news in to the

-node and the
-node. When finished, this would look like:

Once you added this to the search-XML (and restarted your servlet container), you can add your custom document type to your search index. Do this either in the OpenCms administration view of in the xml-file manually.

To do the latter, go to the

and add the following code


Writing specific data to the lucene index

Find more about this on the Writing only specific xml-element-data to the lucene index

Personal tools