Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 445 posts 1059 karma points
    Oct 01, 2014 @ 15:43
    Ayo Adesina
    0

    Using Examine Manager to search content

    Hey guys,

    This is the first time I have used Examine - So far this is working, results variable have the correct data, however what I want to do is add the searchTerm variable I want to search all feilds of all nodes that currently are returned in var results

    Any Ideas? - Thanks in advance.

    var searchEngine = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
    var criteria = searchEngine.CreateSearchCriteria(BooleanOperation.Or);
    
    IBooleanOperation query = criteria.NodeTypeAlias("level1")
    .Or().NodeTypeAlias("level2")
    .Or().NodeTypeAlias("simpleTextPage")
    .Or().NodeTypeAlias("contactPage")
    .Or().NodeTypeAlias("Locationfinder");
    
    string searchTerm = "Term to Search for here";
    
    var results = searchEngine.Search(query.Compile());
    
  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Oct 01, 2014 @ 17:48
    Ismail Mayat
    0

    Ayo,

    Your query would end up being very big, however what you can do is implement gathering node data event then re index to put all the content into one field called contents then you can do search like,

    IBooleanOperation query = criteria.NodeTypeAlias("level1")
    .Or().NodeTypeAlias("level2")
    .Or().NodeTypeAlias("simpleTextPage")
    .Or().NodeTypeAlias("contactPage")
    .Or().NodeTypeAlias("Locationfinder");
    query.And().Field("contents","searchTerm");

    You can see how to do this in this blog post http://thecogworks.co.uk/blog/posts/2012/november/examiness-hints-and-tips-from-the-trenches-part-2/

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft