Copied to clipboard

Flag this post as spam?

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


  • Graeme W 113 posts 289 karma points
    Apr 16, 2014 @ 17:52
    Graeme W
    0

    Examine - specifying document types to search

    I am trying to configure my Examine search to include a limited number of document types. What I've got so far is below

    var criteria = ExamineManager.Instance.CreateSearchCriteria();
    
            var expression = criteria.GroupedOr(new string[] { "nodeName", "bodyText" }, searchTerm)
    
                .And()
    
                .Field("nodeTypeAlias", "Standard")
             .Or()
    
                .Field("nodeTypeAlias", "NewsArticle");
    

    This is only half working as it's only finding results in the first document type mentioned - in this case "Standard" - and ignoring any matches in "NewsArticles" documents. If I swap them round it will find matches in NewsArticles

    Can anyone advise how I can tweak this to get results from multiple document types? I need to do this as there are some document types I need to exclude.

    Thanks

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Apr 16, 2014 @ 18:28
    Alex Skrypnyk
    0

    Hi Graeme,

    You can specify docTypes for search in your Examine config file. http://our.umbraco.org/documentation/reference/searching/examine/overview-explanation

    Thanks, Alex

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Apr 16, 2014 @ 18:29
    Ismail Mayat
    0

    Graeme,

    Do a And().GroupedOR on the nodetypealias field

    Regards

    Ismail

  • Graeme W 113 posts 289 karma points
    Apr 23, 2014 @ 15:59
    Graeme W
    1

    Thanks for your replies. Alex - I did try the config file but couldn't get it to work. Must have been doing something wrong.

    Ismail - thanks for that suggestion. I think that would do the trick.

    However I already managed to get it working by using the following syntax to explicitly state which doc types not to include:

    var expression = criteria.GroupedOr(new string[] { "nodeName", "bodyText" }, searchTerm) //which fields to search         
                .Not()  // document types not to search....
                .Field("nodeTypeAlias", "ContentPanel")
               .Not()
               .Field("nodeTypeAlias", "Image")
                 .Not()
               .Field("nodeTypeAlias", "Folder")
                .Not()
               .Field("nodeTypeAlias", "ContentPanels")            
                ;
    

    Thanks again both for your help

Please Sign in or register to post replies

Write your reply to:

Draft