searchluceneorchardcmsorchardcms-1.7

How to use lucene query syntax on Orchard CMS


I would like to use the full Lucene query syntax on an Orchard CMS based Website.

Currently, after enabling the indexing and search on Orchard, I can search on the website according to the fields I selected on the Orchard search administration page,

From the logs, I can see that Orchard take care of that part (providing Lucene a good query syntax), but I would like to do it on my own. For example, when searching "wel" on the website, Orchard will send to Lucene this query : title:wel* body:wel* (if I have the title and body fields activated on the search).

I did see some blogs that talk about coding some features to customize search, but I would like to be sure I'm not missing something before switching to developer mode :)


Solution

  • There are so many scenarios that can be done with search that there is no way to provide such coverage out of the box, which is why the API is very simple to use if you need custom searching capabilities.

    You should copy-paste the controller from the search module and use the Parse() method of the ISearchBuilder with the escape parameter to false. This will parse a pure lucene query. You can also use the WithField("body", "value") to do simpler field search.