Copied to clipboard

Flag this post as spam?

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


  • Anthony Candaele 1197 posts 2049 karma points
    Sep 30, 2013 @ 14:05
    Anthony Candaele
    0

    different searches on every page

    Hi,

    The scenario I would like to implement on my new Umbraco project (http://testcjs.ugent.be) is to enable a different on every page.

    For example, on the home page I would like to have a search function that does a global search on the website.

    On the publications page I would like to have a search function that only searches the publication nodes.

    On the Research page I would like to have a search function that only searches the Research Project nodes

    etc ...

    Is this possible with Examine? Anyone else implemented a scenario like this?

    thanks for your help,

    Anthony

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Sep 30, 2013 @ 17:40
    Ismail Mayat
    1

    Anthony,

    Depending on how the publication nodes and research project nodes are setup. Are they both one type but just under different pages or different types? Depending on this you have 2 options:

    1. If same type - You will need to implement gathingnode data event and inject in a searchable path into the index then when you are doing the search use the path property as search parameter see more here http://thecogworks.co.uk/blog/posts/2012/november/examiness-hints-and-tips-from-the-trenches-part-2/

    2. If they are of different types then slightly easier what you would do in your macro is to test which section you are in and if in publications or projects do a search just for those types using nodetypealias as filter in the search.

    Regards

    Ismail

  • Anthony Candaele 1197 posts 2049 karma points
    Sep 30, 2013 @ 19:31
    Anthony Candaele
    0

    Hi Ismail,

    Thanks for this advice. I'll try it out and let yoiu know.

    greetings,

    Anthony

  • Anthony Candaele 1197 posts 2049 karma points
    Oct 01, 2013 @ 13:47
    Anthony Candaele
    0

    Hi Ismail,

    I think I go for the second solution. My only question is, how can I do a search only on I node type, eg 'MediaArticle'?

    My current search query, for a global search is defined like this:

    var searcher = ExamineManager.Instance.SearchProviderCollection["CJSSearcher"];
    var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
    
    var query = searchCriteria.GroupedOr(new string[] { "nodeName", "bodyText", "metaDescription" }, searchTerm).Compile();
    

    thanks for your help,

    Anthony

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Oct 01, 2013 @ 13:52
    Ismail Mayat
    0

    Anthony,

    var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or)
    
    var examineQuery = searchCriteria.NodeTypeAlias("MediaArticle");
    
    examineQuery=examineQuery.GroupedOr(new string[] { "nodeName", "bodyText", "metaDescription" }, searchTerm).Compile();
    

    Regards

    Ismail

  • Anthony Candaele 1197 posts 2049 karma points
    Oct 01, 2013 @ 13:54
    Anthony Candaele
    0

    Oh I see, that's easy. Thanks!

  • Anthony Candaele 1197 posts 2049 karma points
    Oct 01, 2013 @ 15:27
    Anthony Candaele
    0

    There is a problem with the line:

    examineQuery=examineQuery.GroupedOr(new string[] { "nodeName", "bodyText", "metaDescription" }, searchTerm).Compile();
    

    The compiler is not recognizing the GroupedOr method:

    Error   20  'Examine.SearchCriteria.IBooleanOperation' does not contain a definition for 'GroupedOr' and no extension method 'GroupedOr' accepting a first argument of type 'Examine.SearchCriteria.IBooleanOperation' could be found (are you missing a using directive or an assembly reference?)
    
  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Oct 01, 2013 @ 15:30
    Ismail Mayat
    0

    Anthony,

    WHen i ever i work with exmaine i just add all fields i want to on into one big field called contents then search on that then there is no groupedor etc also if later new fields are added that i want to search on i dont have to modify code. See http://thecogworks.co.uk/blog/posts/2012/november/examiness-hints-and-tips-from-the-trenches-part-2 there is code on how to munge into one field.

    Regards

    Ismail

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies