使一把umbraco一个可选的搜索 [英] Make a optional search in umbraco

查看:144
本文介绍了使一把umbraco一个可选的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了新的文档类型在内容这个文件类型做了一些节点。
我将成立一个新的搜索索引,以便发现这个code,设立一个新的搜索索引。

I made new document type in umbraco.then made some node by this document type in content. i will set up a new search index so found this code that Setting up a new search index.

@* Get the search term from query string *@
@{var searchTerm = Request.QueryString["search"];}
@{var results = ExamineManager.Instance.Search(searchTerm, true); }

但我不知道如何限制这个code,可以在我的文档类型仅搜索。

but i do not know how to limited this code that can search only in my document type.

推荐答案

有几个步骤这一点。

您将有:


  • 创建一个 ISearchCriteria 对象;

  • 从标准的对象创建搜索前pression,包括DOCTYPE别名要搜索一个领域;

  • 使用前pression搜索。

这可能是codeD为:

This can be coded as:

var criteria = ExamineManager.Instance.CreateSearchCriteria();

var expression = criteria.Field("nodeTypeAlias", "yourDocTypeAlias")
                         .And()
                         .Field("nodeName", searchTerm);

var results = ExamineManager.Instance.Search(expression.Compile());

这是可能的,因为当一把umbraco发布的节点,这样可以节省节点的DOCTYPE别名搜索索引。

This is possible because when Umbraco publishes a node, it saves the node's docType alias to the search index.

有更多这里检查文档。我还建议下载卢克这是一个独立的工具,让你看看索引里面,所以你可以看到什么是一把umbraco实际存储。

There is more Examine documentation here. I would also recommend downloading Luke which is a standalone tool that will allow you to look inside an index so you can see what is actually stored by Umbraco.

这篇关于使一把umbraco一个可选的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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