How to Include Module Content in the Search Results

Topics: Writing modules
Oct 19, 2011 at 9:09 PM

Is there a way to have the content of a Module View included in the search indexing and, therefore, returned in the search results.  

 

 

 

Coordinator
Oct 19, 2011 at 9:46 PM

In an event handler, just subscribe to the Indexing event. Take a look as some usages in BodyPartDriver, or TagsPartDriver.

Oct 20, 2011 at 9:07 AM

I couldn't find a BodyPartDirver but I found the TagsPartDriver in the Tags Module. However, I couldn't see any reference to Indexing. Could you provide a bit more detail or point me towards any resources that might provide some examples.

For you Information, this is what I have created as a test: - Using the HelloWorld Example, I created my own Module. I have a HomeController that returns a single View. The View just returns some HTML markup and some content from our ERP Database.

 

 

Oct 20, 2011 at 2:07 PM

Sebastien must have meant BodyPartHandler, not driver. The former is in the Orchard.Core project, under Common/Handlers.

Oct 20, 2011 at 9:53 PM

I have looked at the BodyPartDriver and have read the documentation. on ContentHandlers. The documentation explains how to create a module that contains records (Parts) in the DB. As a result. the indexing can be added against these parts. However, the Module I have created contains no parts. It is a simple module that just has a Controller and a View.

Can the Indexing be setup against the markup that is generated by the modules view. If so, I cannot see how to do this so an simple example would be appreciated.

 

Using the HelloWorld example http://www.orchardproject.net/docs/Building-a-hello-world-module.ashx, can a handler be added that would add the output of the view to the index so that if I searched for HelloWorld, it would take me to the page containing the module.

 

 

Coordinator
Oct 20, 2011 at 10:57 PM

The current search engine can only work on content items. If you want to search for static content, you will need another module handling that.

Oct 21, 2011 at 9:52 AM

Ok - Thanks. Is there another search module available that can handle this? Some of the content that I would want to include in the CMS would not be stored in the Orchard DB, it might be from a number of sources so we would need a search module that could include this.

This is a feature that will be added to the current search module?

 

 

Coordinator
Oct 21, 2011 at 6:03 PM

The easiest solution I currently see is to use Bing or Google APIs to index your content, and request it. This is a pretty common scenario, look at how doc.nuget.org is doing it.