Copied to clipboard

Flag this post as spam?

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


  • Liam Dilley 148 posts 374 karma points
    Jun 17, 2020 @ 03:23
    Liam Dilley
    0

    Umbraco 8 multi field search with multi node tree pickers

    Hey all, I have only done Core searches and a bit more advanced in Umbraco 7 and with a new site build hit with a search challenge I hope you can help with.

    I have tried to search here and follow some other threads but they not quite what I am after or old Umbraco 7 which do not work in 8.

    I have the following search:

    enter image description here

    I pass to a search results page and pull URL Queries out.

    Keywords - Will search various fields of the document type. I believe I have this sorted:

    var textFields = new[] { "title", "description",  "content", "projectContent", "projectSummary",};
    

    With the results being:

    var results = advancedSearcher.CreateQuery("content").NodeTypeAlias("Project").And().GroupedOr(textFields, searchKeyword)
    

    But the other fields are where I am struggling.

    Organisation is a multi node tree picker so it would need to search through names of those nodes.

    Project staff is also a multi node tree picker so it would need to search through the names of those nodes as well.

    I want to get it working with one word but ideally a number of words per field as well.

    I was trying along the lines of the below code but it was not working or returning the results expected:

    var results = advancedSearcher.CreateQuery("content").GroupedOr(new[] { "__NodeTypeAlias" }, new[] { "Project" })
                                //.And()
                                //.GroupedOr(fields, searchKeyword != "" ? searchKeyword.ToString() : searchKeyword.ToString())
                                //.And()
                                //.Field("projectRelatedPartners", (searchOrganisation != null ? searchOrganisation.ToString().MultipleCharacterWildcard() : ""))
                                //.And()
                                //.Field("projectContent", searchKeyword)
                                //.Or()
                                //.Field("nodeName", searchKeyword)
                                //.Execute();
    

    Can anyone help?

    Thank You

  • Liam Dilley 148 posts 374 karma points
    Jul 14, 2020 @ 01:37
    Liam Dilley
    0

    No one got back on this. We ended up running a pass to get some results and then running another after that to filter down further, trying to combine multiple fields from objects was all in one request just did not return anything.

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jul 14, 2020 @ 09:16
    Ismail Mayat
    0

    Liam,

    The multi node tree picker stores udi's not that actual text values. You are trying to search using text but the stored value is udi.

    You can either use transforming node event and inject in text values by getting the udi and getting the node and its text value or at point of search from the text value get the node and its udi then search using udi.

    See

    https://our.umbraco.com/documentation/reference/searching/examine/examine-events

    Regards

    Ismail

  • Liam Dilley 148 posts 374 karma points
    Jul 15, 2020 @ 03:23
    Liam Dilley
    0

    This is helpful Ismail, Thanks. I will go through it for the next project.

Please Sign in or register to post replies

Write your reply to:

Draft