我们可以分配一个以上的模板ID在templateId(就像我们在做relatedId),而使用Lucene搜索? [英] Can we assign more then one template ID in templateId (like we do in relatedId), while searching with Lucene?

查看:151
本文介绍了我们可以分配一个以上的模板ID在templateId(就像我们在做relatedId),而使用Lucene搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有五个复选框




  • 搜索所有

  • 模板1

  • 模板2

  • 模板3

  • 模板4



如果用户选择了搜索所有,后来干脆我们可以通过索引名和获得的结果,如果用户选择模板具体复选框之一,又简单我们可以通过将模板名称做的,但如果有两个模板具体复选框(或可能成为三级)进行检查,然后呢?



我们能否管分离templateIDs <? / p>

解决方案

您可能需要更改该方法中的高级数据库抓取来处理传入模板的GUID。在 SearchParam 类有一个叫做物业 TemplateIds 这由是复数表示,应该允许多个。但是,如果你看看代码,这是它的使用方式:

  templateIds = IdHelper.NormalizeGuid(templateIds); 



NormalizeGuid()方法实际上<一个HREF =htt​​p://svn.sitecore.net/AdvancedDatabaseCrawler/Branches/v2/Sitecore.SharedSource.Searcher/Utilities/IdHelper.cs相对=nofollow>只返回一个GUID 。所以,我建议你修改 ApplyTemplateFilter()方法在这里返回多个模板的GUID:

 保护无效ApplyTemplateFilter(CombinedQuery查询字符串templateIds,QueryOccurance次数)
{
如果(String.IsNullOrEmpty(templateIds))回报;

templateIds = IdHelper.NormalizeGuid(templateIds);
变种fieldQuery =新FieldQuery(BuiltinFields.Template,templateIds);
query.Add(fieldQuery,次数);
}



所以变化 templateIds = IdHelper.NormalizeGuid(templateIds) 也许在拆分输入来处理多个的GUID,| 来获取每个GUID然后正常化的每一个人,并通过再次将它们合并 |


I have Five check boxes

  • Search All
  • Template 1
  • Template 2
  • Template 3
  • Template 4

If user selects Search All, then simply we can pass index name and get result, if user selects one of template specific check box, again simply we can do by passing template name, but if any of two templates specific check box(or may be three) are checked, then?

Can we pipe-separate templateIDs?

解决方案

You may need to change the method in the Advanced Database Crawler to handle the GUIDs of templates passed in. The SearchParam class has a property called TemplateIds which by being plural indicates it should allow more than one. However, if you look into the code, this is how it is used:

templateIds = IdHelper.NormalizeGuid(templateIds);

The NormalizeGuid() method actually only returns a single GUID. So I recommend you alter the ApplyTemplateFilter() method here to return multiple Template GUIDs:

protected void ApplyTemplateFilter(CombinedQuery query, string templateIds, QueryOccurance occurance)
{
  if (String.IsNullOrEmpty(templateIds)) return;

  templateIds = IdHelper.NormalizeGuid(templateIds);
  var fieldQuery = new FieldQuery(BuiltinFields.Template, templateIds);
  query.Add(fieldQuery, occurance);
}

So change templateIds = IdHelper.NormalizeGuid(templateIds) to handle multiple GUIDs, perhaps by splitting the input at a | to get each GUID then normalizing each one of those and combining them again via a |.

这篇关于我们可以分配一个以上的模板ID在templateId(就像我们在做relatedId),而使用Lucene搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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