Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Francis 12 posts 43 karma points
    May 04, 2017 @ 08:56
    Francis
    0

    Examine not returning custom fields

    Hi everyone.

    I am creating a search index. I've added a custom field into the index using: e.Fields.Add("_language", "en");

    as a GatheringNodeData event. I can see this field and value when looking inside Luke at the index and I can search for it inside examine management e.g. +_language:en

    However, when I search from Examine, I get no results. I have debugged through the code and all fields apart from custom fields are returned by Examine. In that same code, I can search for the usual fields just fine, as soon as I add to search the _language field, nothing is returned.

    I'm using Umbraco 7.5.13. Any ideas what I'm doing wrong?

    Thank you.

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    May 04, 2017 @ 09:30
    Ismail Mayat
    0

    Francis,

    Can you paste back your search code.

    Regards

    Ismail

  • Francis 12 posts 43 karma points
    May 04, 2017 @ 09:43
    Francis
    0

    Hi,

    Thanks for the reply.

    The search code that is running is:

    var externalSearcher = ExamineManager.Instance.SearchProviderCollection["MySearcher"];
            var criteria = externalSearcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);
    
            var query = criteria.Field("_language", "en");
    
            return ExamineManager.Instance.Search(query.Compile());
    

    If I change to:

    var externalSearcher = ExamineManager.Instance.SearchProviderCollection["MySearcher"];
            var criteria = externalSearcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);
    
            var query = criteria.Field("title", "any title here");
    
            return ExamineManager.Instance.Search(query.Compile());
    

    It returns search results.

    In Luke, I have the results coming through without an issue: enter image description here

    Thanks.

  • Francis 12 posts 43 karma points
    May 04, 2017 @ 13:31
    Francis
    0

    I found the issue. I should have been doing:

    var externalSearcher = ExamineManager.Instance.SearchProviderCollection["MySearcher"];
        var criteria = externalSearcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);
    
        var query = criteria.Field("_language", "en");
    
        return externalSearcher.Search(query.Compile());
    

    rather than using:

    return ExamineManager.Instance.Search(query.Compile());
    

    Thanks for your help. Hopefully this helps someone else.

Please Sign in or register to post replies

Write your reply to:

Draft