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"))

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();


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


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


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"]


i => i["peer_group_sm"]

everything worked. Go figure.

  • Have you tried with lowercase template name? or replacing template name with template id? – Marek Musielak Feb 25 '19 at 10:09
  • I will right away. – Emanuele Ciriachi Feb 25 '19 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. – Emanuele Ciriachi Feb 25 '19 at 10:21
  • Can you post your code that is not returning the results? – Gatogordo Feb 25 '19 at 10:27
  • 1
    I would recommend adding an answer with your solution, since you were able to solve it. – Dan Sinclair Feb 26 '19 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.