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.
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();
}
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:
- I am getting data from SOLR
- And the result has matching categoryId
But I just don't understand why the first one doesn't match it!!
Will appreciate if you could review my POCO and field mapping below:
Field Mapping:
<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; }
}
Noticed below on Search.log
23732 2016:01:23 22:49:46 INFO Serialized Query - ?q=articlecategory_s:(e83405719a5c4ff18595d685c9103e0f)&rows=2147483647&fl=*,score&fq=_indexname:(sitecore_web_index)
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)