Different search boxes for different content types

Topics: Customizing Orchard
Jul 27, 2012 at 1:13 PM

So I need two search boxes on every page on my site. One to search pages and another for a custom content type. What would be the best way to implement this in 1.5.1 ?

Jul 29, 2012 at 1:52 PM
Edited Jul 29, 2012 at 1:53 PM

The SearchController of the Search module doesn't support any other criteria than a text string to search in the indexed content, so I think there are at least 2 valid approaches: 1) fork the search module to make it extensible (perhaps introduce some sort of search filter providers so that custom modules can inject filters, or 2) create your own controller, taking the SearchController as an example and tweak it as desired.

Next, it would simply be a matter of posting your search box content to your controller.

Jul 29, 2012 at 2:14 PM

Another approach would be to add full-text filters to Projections.

Jul 29, 2012 at 2:15 PM

Oh! I like that. No code required.

Aug 2, 2012 at 9:57 AM

Thanks guys

Projections work, but seem a little bit slow. Do I understand correctly that queries go to the DB on every page view, while search uses Lucene?

Aug 2, 2012 at 3:40 PM

Slow? Really? If you can provide profiling information in your specific setting, it would be interesting to file a bug with it.

Of course queries go against the DB, but there's little difference with search: Lucene does get queried, but then the actual content items need to be retrieved as well, so the DB gets hit too.

Aug 9, 2012 at 4:38 PM

I can see in SQL Server profiler, that refresing a page containing a single projection widget generates over a hundred SQL commands. My hope is that in 1.6 nHibernate 2nd level and query caches will get rid of this load.

Aug 10, 2012 at 2:59 AM

What is the projection doing? Did you try the cache module, which is available today?

Aug 10, 2012 at 3:59 PM

It has 3 filter groups with 3 filter each and a single sort criteria.


I haven't tried the cache module. My site  will be going live no sooner than October and I thought there's a chance 1.6 will be released by then.

Aug 28, 2012 at 5:16 AM

Well, you know, output caching is still relevant even if you have DB caching.