How to use lucene query syntax on Orchard CMS

浪尽此生 提交于 2019-12-11 04:38:49

问题


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,

  • but I cannot perform one search on a particular field only (without changing the behavior on the entire search)
  • I cannot use fuzzy search...

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 :)


回答1:


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.




回答2:


I don't believe anyone has released any modules that provide additional search functionality, because if you need it, it is so simple to develop ^_^ So yes, you will have to go dev mode to do custom field search



来源:https://stackoverflow.com/questions/19555659/how-to-use-lucene-query-syntax-on-orchard-cms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!