Copied to clipboard

Flag this post as spam?

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


  • Jesp3r 4 posts 24 karma points
    Nov 17, 2014 @ 13:32
    Jesp3r
    0

    Examine: Multiple searchPath's?

    I need to limit my Lucene/Examine search to two searchPaths (rootNodes from multi site solution). So i need to search two sites out of 10 for instance.

    But how do i config my query to accomplish this? I tried a variaty of things, but none have worked.

    This is what i have now;

    -umbracoNaviHide:1 +((__IndexType:content +searchPath:1056 -template:0) +(body:test*) body:test*^1
    

    This works fine, but only searches from one root node.

    I tried the following, with no success;

    +searchPath:1056 +searchPath:1441
    +searchPath:1056,1441
    +searchPath:1056+1441
    +searchPath:1056 1441
    

    Any ideas?

  • Sotiris Filippidis 286 posts 1501 karma points
    Apr 30, 2020 @ 20:05
    Sotiris Filippidis
    0

    Wow, a question from 2014 the topic of which troubled me in 2020! I'm facing the same problem - I want to either include multiple searchPaths or exclude multiple searchPaths, but it doesn't seem to be working at all. I'm constructing a raw query and done all the OP has done. Any hints?

  • MB 113 posts 422 karma points
    Feb 16, 2021 @ 01:43
    MB
    0

    More necro posting, but FWIW - just had to solve this myself on a v7 site.

    In this 'works for me' solution, the trick seems to be that it needs to be a groupedOr so that the Examine will search for multiple values on the same key.

    The raw syntax for the multiple paths looks something like (assuming you save the fields with commas replaced by spaces):

    +(searchPath:"1 1056" searchPath:"1 1441")
    

    The v7 API to add this is something like: (assuming these are both root child nodes)

    var criteria = baseSearchProvider.CreateSearchCriteria(BooleanOperation.And);
    var searchPaths = new List<string>();
    searchPaths.Add(node1.Path.Replace(",", " "));
    searchPaths.Add(node2.Path.Replace(",", " "));
    var examineQuery = criteria.GroupedOr(new string[] { "searchPath" }, searchPaths.ToArray());
    examineQuery = examineQuery.And().whatever-other-filters...
    
Please Sign in or register to post replies

Write your reply to:

Draft