Copied to clipboard

Flag this post as spam?

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


  • jake williamson 172 posts 762 karma points
    Sep 04, 2019 @ 02:11
    jake williamson
    0

    v8 examine search by 'parentID' doesn't return any results?!

    hey out there,

    this is a weird one, not sure if it's me or a bug...

    in v7 i used to filter by parent id using +parentID:1172 as a lucene search:

    enter image description here

    however the same query isn't working in v8! i've defo got items in the index e.g.

    enter image description here

    but when i run the search, no items come back...

    enter image description here

    although v8 is missing the toggle between a text search and a lucene search the search seems to accept lucene based searches as something like +__NodeTypeAlias:blogpost +postDateYearAndMonth:2019-sep works:

    enter image description here

    am i missing something obvious here?!?!

  • jake williamson 172 posts 762 karma points
    Sep 04, 2019 @ 05:42
    jake williamson
    0

    ok, so this is interesting. i did some debugging of the search code i'd written and looked at the examine query and it's looks a little weird...

    this is the code:

    var parentId = 2287;
    var query = searcher.CreateQuery("content")
        .Field("__NodeTypeAlias", "BlogPost")
        .And();
    
    query.Field("parentID", parentId).And();
    
    var results = query.All().Execute();
    totalRecords = results.TotalItemCount;
    

    which generates a lucene query of:

    +__NodeTypeAlias:blogpost +(parentID:[2287 TO 2287])
    

    and i get results back!

    however, if i take that lucene query and paste it into luke to test the query i get nothing back...

    if i change the query to:

    +__NodeTypeAlias:blogpost parentID:[2287 TO 2287]
    

    then i get results!

    seriously confused...

  • jake williamson 172 posts 762 karma points
    Sep 04, 2019 @ 05:46
    jake williamson
    0

    the knock on of all this is that at some point i want to be able to do a GroupedOr query e.g.

    get me all the blog posts that have the parentId 1234 or 5678 or 9101

    but GroupedOr only allows strings to be passed to it...

  • James Kent-Nye 2 posts 71 karma points
    5 days ago
    James Kent-Nye
    0

    I've been upgrading a site to Umbraco 8 over a year later from the OP and ran into exactly the same issue...

    Examine can't seem to find content based on a single parentID (even though it is definitely in the index), a query that did work in Umbraco 7

    enter image description here But when I change it to +(parentID:[1119 TO 1119]) it is able to find the data correctly

    enter image description here

    I'm new to the formal community (first post!), so I'm not sure whether this has been reported as a bug or fixed (although I am using v8.10.1) - but any explanation why this has changed would be great!

  • James Kent-Nye 2 posts 71 karma points
    5 days ago
    James Kent-Nye
    0

    So following on from my last post, I've got it working again in the code, and I think I know what was causing my issue...

    My previous query was getting the parentID as a string:

    string selectedID = DataNode.Id.ToString();
    thisQuery.And().Field("parentID", selectedID );
    

    This was working in v7, but not in v8. So following on from the +(parentID:[1119 TO 1119]) query working in the ExternalIndex, I made a range query to replicate it, which worked:

    int selectedID = DataNode.Id;
    thisQuery.And().RangeQuery<int>(new string[] { "parentID" }, selectedID , selectedID );
    

    On reflection however, I think the important thing is that the parentID data is treated as an int, not as a string when being added to the query, as this works too:

    int selectedID = DataNode.Id;
    thisQuery.And().Field("parentID", selectedID);
    

    Interestingly in debug this generates a +(parentID:[1119 TO 1119]) query rather than +parentID:1119, although the only thing that has changed is the datatype of the selectedID

    So I suspect there is a bug with the index searcher in the umbraco CMS not treating +parentID:1119 as an int, but instead a string for some reason, but at least its working on my end now!

Please Sign in or register to post replies

Write your reply to:

Draft