Copied to clipboard

Flag this post as spam?

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


  • Matt Taylor 873 posts 2086 karma points
    May 30, 2013 @ 11:30
    Matt Taylor
    0

    Examine - choosing a search index parent or start node dynamically

    In my site I have various news sections which can be created by the editor.

    News
    - Technology
    -- News article 1
    -- News article 2
    - Politics
    -- News article 3
    -- News article 4
    - Business
    -- News article 5
    - Education
    -- News article 6
    -- News article 7
    -- News article 8

    Elsewhere on the site the editor can add a serach macro and tell this macro which news section to search by selecting the applicable node (Technology, Politics, Business or Education).

    Creating a seperate index for each of the news sections is not the thing to do because the editor is free to add new ones when they like.

    I would like to have a single index with the IndexParentId set to the 'News' node but be able to specify at run time to only look at children of a particular news section node (Technology, Politics, Business or Education).

    How can I do this?

    The news section nodes are all the same document type by the way.

    Regards,

    Matt

  • Matt Taylor 873 posts 2086 karma points
    May 31, 2013 @ 16:42
    Matt Taylor
    100

    I found the answer here.

  • Matt Taylor 873 posts 2086 karma points
    May 31, 2013 @ 16:43
    Matt Taylor
    0

     

    Create searchable path

    If you want to create search driven components like news listers then you can create Umbraco Examine queries to list all child documents of a particular parent, e.g. all news articles in the news section.  This would be done by searching for all documents that contain the parent news section document id in the path.  

    The path is stored in the index, however its stored as a csv list e.g:-

     1,1056,1078

    In order to execute a search to find all news items with parent 1056 in the path, we would need to massage the path data into a format that is searchable. So using the GatheringNodeData event we can replace the commas in the path with a space and inject into new field called searchablePath. We can then perform a search in this field and we will get our end result.

  • Matt Taylor 873 posts 2086 karma points
    May 31, 2013 @ 16:44
    Matt Taylor
    0

    You do need to add 'path' to your index though. Eaxmine does add a '__Path' field of its own but I couldn't use that one.

Please Sign in or register to post replies

Write your reply to:

Draft