如何在Orchard CMS上使用Lucene查询语法 [英] How to use lucene query syntax on Orchard CMS

查看:108
本文介绍了如何在Orchard CMS上使用Lucene查询语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Orchard CMS上使用完整的 Lucene查询语法基础的网站.

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

当前,在Orchard上启用索引和搜索后,我可以搜索在网站上,根据我在果园搜索管理"页面上选择的字段,

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,

  • 但是我不能仅对特定字段执行一次搜索(不更改整个搜索的行为)
  • 我无法使用模糊搜索...

从日志中,我可以看到Orchard负责这一部分(为Lucene提供了良好的查询语法),但是我想自己做. 例如,在网站上搜索"wel"时,Orchard会将以下查询发送给Lucene:title:wel * body:wel *(如果我在搜索中激活了title和body字段).

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

推荐答案

搜索可以完成很多场景,因此无法提供这种覆盖范围的方法,这就是API非常简单的原因需要自定义搜索功能时可以使用.

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.

您应该从搜索模块复制粘贴控制器,然后将ISearchBuilder的Parse()方法和escape参数设置为false.这将解析一个纯Lucene查询.您还可以使用WithField("body", "value")进行更简单的字段搜索.

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.

这篇关于如何在Orchard CMS上使用Lucene查询语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆