Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 21, 2010 @ 17:45
    Ismail Mayat
    0

    Examine node id or question

    Guys,

    I need to do a node range query using examine i have csv list of nodes so want all nodes with the values in the list i am doing something like

    if (Request.QueryString["id"]!=null)
    {
        string[] ids = Request.QueryString["id"].Split(new char[] {','});                
        query = ids.Aggregate(query, (current, id) => current.Or().Id(int.Parse(id)));
    }

    when i pass in 2 ids i should get 2 results but get more the query that is generated looks like

    +(+nodeTypeAlias:product __NodeId:1217 __NodeId:1328) +__IndexType:content 

    its not restrictive enough becuase its matching on nodetypealias.

    Regards

    Ismail

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 22, 2010 @ 00:48
    Aaron Powell
    1

    You want to AND a GroupedOr statement onto the nodeTypeAlias check, so in plane english what your query looks like is:

    When NodeTypeAlias is Product and NodeId is in the CSV

    So you want to build a Lucene query like this:

    +nodeTypeAlias:product +(__NodeId:1217 __NodeId:1328)

    (and then append the index type check)

    Try this: (I think that the indexer class exposes a property which is the magic string for NodeId so you don't have to hard-code it)

    if (Request.QueryString["id"]!=null)

    {

        string[] ids = Request.QueryString["id"].Split(new char[] {','});                

        query = query.And().GroupedOr(ids.Select(x => "__NodeId"), ids);

    }

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 22, 2010 @ 08:27
    Ismail Mayat
    0

    Slace,

    Awesome that worked a treat!

    Regards

    Isamil

  • Rich Green 2246 posts 4008 karma points
    Sep 22, 2010 @ 08:37
    Rich Green
    0

    Hey Ismail,

    Are you matching multiple ID's here? Sorry to jump on this post but seems to be almost what I need but I'm having trouble understanding this code.

    It looks like your CSV values being passed in via the querystring?

    I have a bunch of ID's selected from MNTP set to CSV, I split these and get them into the examine index ok, but I don't know that the examine statement to search them.

    I have these values from my MNTP "1010,1012,1020" I need to find results only where ALL these nodes have been selected.

    Hope this makes sense and that it has something to do with this post...

    Cheers

    Rich 

     

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 22, 2010 @ 08:42
    Aaron Powell
    0

    You should attach to the GatheringNodeData event and split the CSV on "," and replace it with " ". This way they are indexed individually and can be searched individually.

  • Rich Green 2246 posts 4008 karma points
    Sep 22, 2010 @ 08:52
    Rich Green
    0

    Hey Slace,

    I've done that bit and they are indexed separately, however I don't know what examine search term to use?

    Cheers

    Rich

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 22, 2010 @ 09:00
    Ismail Mayat
    0

    Rich,

    I have a product search page and users can search on bunch of fields.  I also have a supplier page and they have link called products offered by supplier.  Each supplier has using MNTP a bunch of products set so the link has href /product-search?ids=1234,1235,3445 on results page i perform query as per Slaces suggestion and it works nicely.  The productsoffered should be in index as field but its not however as the product ids are node ids i can search on id or __NodeId and it works.

    Regards

    Ismail

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 22, 2010 @ 09:13
    Aaron Powell
    0

    Rich - Start a new thread so your problem doesn't get lost in this one and it's easier for others to if they have your problem in the future :). Flick it to me on twitter once you're done :)

  • Rich Green 2246 posts 4008 karma points
    Sep 22, 2010 @ 09:48
    Rich Green
    0

    Thank you Slace & Ismail.

    Added a thread to a post I started a while back, linked here for anyone looking http://our.umbraco.org/forum/developers/extending-umbraco/12345--MultiNodePicker-Examine hopefully explains my problem clearly.

    Rich

  • 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