从Lucene切换后,Sitecore GetQueryable筛选器未为SOLR返回任何结果 [英] Sitecore GetQueryable Filter not returning any result for SOLR after switch from Lucene

查看:86
本文介绍了从Lucene切换后,Sitecore GetQueryable筛选器未为SOLR返回任何结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Sitecore Lucene搜索提供程序转换为Solr.内核已配置完毕,我可以毫无问题地重建所有CORE.

I'm in process of switching the Sitecore Lucene Search provider to Solr. Cores have been configured and I can rebuild all the COREs with no problem.

我还根据Solr映射要求更新了计算的索引字段.但是,出于奇怪的原因,下面的查询未返回任何结果.

I also updated the computed index fields per Solr mapping requirements. However, for weird reason the query below isn't returning any results.

using (var context = index.CreateSearchContext(SearchSecurityOptions.DisableSecurityCheck))
            {

                var query = context.GetQueryable<ArticleSearchResultItem>().Filter(item => item.Category == categoryId);

                var results = query.GetResults();
}

但是当我这样做时,我可以匹配categoryid,即如果条件允许,我可以打进里面.

But when I do this I can match the categoryid i.e. I can hit inside if condition.

using (var context = index.CreateSearchContext(SearchSecurityOptions.DisableSecurityCheck))
            {
                var query1 = context.GetQueryable<ArticleSearchResultItem>();
                foreach (var q in query1)
                {
                    if (q.Category == categoryId)
                    {
                        //Matched Category ID
                    }
                }

}

上面的第二项测试确认:

The second test above confirms that:

  1. 我正在从SOLR获取数据
  2. 结果具有匹配的categoryId

但是我只是不明白为什么第一个与它不匹配!

But I just don't understand why the first one doesn't match it!!

如果您可以在下面查看我的POCO和字段映射,将不胜感激

Will appreciate if you could review my POCO and field mapping below:

字段映射:

<fields hint="raw:AddComputedIndexField">
              field fieldName="articlecategory" returnType="string">MyNameSpace.ComputedFields.ArticleCategoryField, MyNameSpace.Business</field>
              ....

POCO:

public class ArticleSearchResultItem : BaseSearchItem
    {
        [IndexField("articlecategory")]
        [TypeConverter(typeof(IndexFieldIDValueConverter))]
        public ID Category { get; set; }
        }

以下在Search.log上标出

Noticed below on Search.log

23732 2016:01:23 22:49:46 INFO序列化查询-?q = articlecategory_s:(e83405719a5c4ff18595d685c9103e0f)& rows = 2147483647& fl = *,score& fq = _indexname:(sitecore_web_index)

23732 2016:01:23 22:49:46 INFO Serialized Query - ?q=articlecategory_s:(e83405719a5c4ff18595d685c9103e0f)&rows=2147483647&fl=*,score&fq=_indexname:(sitecore_web_index)

尝试将下面的查询粘贴到Solr Admin上,什么也不会返回.

Tried copy paste the query below on to Solr Admin, nothing gets returned.

?q=articlecategory_s:(e83405719a5c4ff18595d685c9103e0f)&rows=2147483647&fl=*,score&fq=_indexname:(sitecore_web_index)

推荐答案

已成功解决此问题..

问题在于,计算索引字段具有将ID转换为简短GUID的逻辑.

The issue was that computed index field had a logic where ID was converted to short guid.

我删除了这一行并重新编制了索引,并开始从SOLR中获取数据.

I removed this line and re-indexed and started getting data from SOLR.

这篇关于从Lucene切换后,Sitecore GetQueryable筛选器未为SOLR返回任何结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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