1

I'm on Solr 4.10.4, Sitecore 8.1 160519.

I have a query used internally by my application that returns 0 records.

In the Search.log I can see that same query; if I copy the querystring value to the Solr web UI, it returns the results I expect from it.

?q=((_path:(0de95ae441ab4d019eb067441b7c2450) AND enabled_b:(True))
AND _templatename:("Base Person"))
&start=0
&rows=20
&fl=*,score
&fq=_indexname:(sitecore_web_index)

This is the C# code that performs the query. It's the same code that worked for Lucene.

var filter = PredicateBuilder.True<BasePerson>();

filter = filter
    .And(i => i.ItemAncestors.Contains(GlobalDefinitions.Data.ContentRoot))
    .And(i => i.Enabled);

Expression<Func<BasePerson, object>>[] facetsFilter = {
    i => i[GlobalDefinitions.IndexFields.ParsedLocation],
    i => i[GlobalDefinitions.IndexFields.ParsedDivisions],
    i => i[GlobalDefinitions.IndexFields.ParsedSpecialisms],
    i => i[GlobalDefinitions.IndexFields.ParsedCapitals],
    i => i[GlobalDefinitions.IndexFields.ParsedHoldings],
    i => i[GlobalDefinitions.IndexFields.ParsedIntelligences],
    i => i[GlobalDefinitions.IndexFields.ParsedStrategies],
    i => i[GlobalDefinitions.IndexFields.ParsedConsultings],
    i => i[GlobalDefinitions.IndexFields.ParsedCapabilities],
    i => i[GlobalDefinitions.IndexFields.PeerGroup],
    i => i[GlobalDefinitions.IndexFields.ParsedSectors] };

filter =
    filter.And(item => (item.TemplateId == GlobalDefinitions.Templates.BasePersonTemplate.Id));

PageInfo pageInfo = null;
if (!noPaging) {
    pageInfo = new PageInfo() {
        Page = page,
        PageSize = pageSize
    };
}

var query = SearchContext.GetQueryable<BasePerson>();
query = query.Where(filter);

foreach (var facet in facets) {
    query = query.FacetOn(facet);
}

query = query.Page(pageInfo.Page, pageInfo.PageSize);

var results = query.GetResults();

Question

Any clues on what could possibly cause this behavior, or what could help me to troubleshoot it?

EDIT

On request, I added the C# code that performs the query.

EDIT 2

Apparently, and surprisingly, the culprits is facets. I modified the code above to include the faceting, that I had removed as I didn't imagine it would make a difference. After switching the PeerGroup facet to the Solr index name, from:

i => i["peer_group"]

to

i => i["peer_group_sm"]

everything worked. Go figure.

13
  • Have you tried with lowercase template name? or replacing template name with template id?
    – Marek Musielak
    Feb 25, 2019 at 10:09
  • I will right away. Feb 25, 2019 at 10:15
  • 1
    Same results: returns 0 results, but if I retrieve the query from Search.log and use it in the Web UI it returns what I expect. Feb 25, 2019 at 10:21
  • Can you post your code that is not returning the results?
    – Gatogordo
    Feb 25, 2019 at 10:27
  • 1
    I would recommend adding an answer with your solution, since you were able to solve it. Feb 26, 2019 at 19:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.