3

I was developing a module for advanced search over liferay content, and I was stuck in document library search, it was asked to search in documents by document type, and I wish to know the feasibility of such feature, I've check liferay code and found that the document library indexer does not index the document extension instead it indexes the whole file name

Kindly help me with this issue

  • I realize that this is not likely want you wanted to hear, but in later versions of Liferay, we started indexing the extension as the "extension" field. It's a one line change to the indexer if you are able to patch your env. document.addKeyword("extension", dlFileEntry.getExtension()); – Ray Nov 22 '11 at 18:09
  • Thanks for your reply, I knew it anyway and started looking for an indexer override and was stuck in it as well, if you have a recommendation for overriding the indexer post a reply there http://stackoverflow.com/questions/8231851/change-liferay-search-indexer Thanks anyway – Mohamed Wagdy Khorshid Nov 22 '11 at 18:31

1 Answers1

1

If you are using 6.0 or higher, you can change the way a document is indexed by using a hook plugin.

Simply define in your liferay-hook.xml

<indexer-post-processor>
    <indexer-class-name>com.liferay.portal.model.DLFileEntry</indexer-class-name>
    <indexer-post-processor-impl>com.example.hook.indexer.DLFileEntryIndexerPostProcessor</indexer-post-processor-impl>
</indexer-post-processor>

In your post processor class extend com.liferay.portal.kernel.search.BaseIndexerPostProcessor and implement the method you need to change up.

In this case you would want to implement postProcessDocument to add in the extension as a indexed field and also postProcessSearchQuery or postProcessFullQuery to include it as part of the search query.

Dani
  • 3,744
  • 4
  • 27
  • 35
rp.
  • 3,435
  • 1
  • 21
  • 29