Copied to clipboard

Flag this post as spam?

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


  • Kristian Ravnevand 94 posts 214 karma points
    Aug 13, 2010 @ 11:42
    Kristian Ravnevand
    0

    Examine quering path

    Hi folks

    I'm tring to make a qiery on examine on the "Path" attribute:

        <IndexAttributeFields>
          <add Name="id" />
          <add Name="nodeName" />
          <add Name="updateDate" />
          <add Name="writerName" />
          <add Name="path" />
          <add Name="nodeTypeAlias" />
          <add Name="parentID" />
        </IndexAttributeFields>

    My thought was that something like this should do the trick:

                    var provider = ExamineManager.Instance;
                    var criteria = provider.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);

                    var filter = criteria
                        .Field("path", "1048").Compile();

    I was wrong :-)

    Anybody have a clue on what i'm doing wrong?

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Aug 13, 2010 @ 13:24
    Ismail Mayat
    0

    Kristian,

    Isnt path stored as csv list so would need some kind of fuzzy logic?  Might also be worth checking how its stored in lucene using luke. I recall in old umbSearch the path was stored as 1055s1056s1057

    Regards

    Ismail

  • Kristian Ravnevand 94 posts 214 karma points
    Aug 16, 2010 @ 08:03
    Kristian Ravnevand
    0

    Hi Ismail, thanks for reply

    In umbraco.config, path is stored as an attribute on the node like this: ---nodeTypeAlias="Article" path="-1,1048,1075,5049">. The main different is as far as I can see that the path is an attribute, while the other properties are elements of the node.

    Example; when searching for all nodes with nodeTypeAlias like "article" they've created an extra extension method: criteria.NodeTypeAlias("article"). So maybe it should be an extension method for path to.

    Tested a bit more. This gives results:

    Examine.ExamineManager.Instance.Search(provider.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content).NodeTypeAlias("article").And().NodeName("test".Fuzzy()).Compile()).First().Fields
    Count = 11
        [0]: {[Lead, lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ]}
        [1]: {[Photo, 30059]}
        [2]: {[ShowByLine, 0]}
        [3]: {[umbracoNaviHide, 0]}
        [4]: {[id, 30064]}
        [5]: {[nodeName, loreum ipsum dolor est sint]}
        [6]: {[updateDate, 20100804121538000]}
        [7]: {[writerName, kristian]}
        [8]: {[path, -1,30050,30063,30064]}
        [9]: {[nodeTypeAlias, article]}
        [10]: {[parentID, 30063]}


    Examine.ExamineManager.Instance.Search(provider.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content).Field("path","-1,30050,30063,30064").Compile())
    {UmbracoExamine.SearchResults}
        [UmbracoExamine.SearchResults]: {UmbracoExamine.SearchResults}
        TotalItemCount: 1

    So if I could get "," to be used as a seperator insted of whitespace, it might work

  • Kristian Ravnevand 94 posts 214 karma points
    Aug 16, 2010 @ 08:56
    Kristian Ravnevand
    0

    Hi again :-)

    Now this works:

    Examine.ExamineManager.Instance.Search(provider.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content).Field("path","-1".MultipleCharacterWildcard().Then("30063").MultipleCharacterWildcard()).Compile())

    Seems a bit crappy, but it did the trick :-)

    Thanks Ismail for the pointer

     

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 22, 2010 @ 15:48
    Ismail Mayat
    0

    Kristian,

    I am trying this with latest examine release my code looks like

     

     var provider = ExamineManager.Instance.SearchProviderCollection[providerName];

     var query =provider.CreateSearchCriteria(IndexTypes.Content);

     

                        query.NodeTypeAlias(nodeTypeAlias).And().Field("path", "-1".MultipleCharacterWildcard().

                            Then(parentNode.ToString().MultipleCharacterWildcard().Value)).

                            And().OrderByDescending(sortField);

     

    var results = provider.Search(query);

    I get query output that looks like +__NodeTypeAlias:newsitem +path:"1 2362" which comes back with nothing.  In you example you dont have .Value at end of MultipleWildCard() but if i dont have it then i get syntax error could be due to latest version examine changes.

    Any ideas?

    Regards

    Ismail

     

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 22, 2010 @ 17:01
    Ismail Mayat
    1

    In answer to me question for now i used rawquery namely +__NodeTypeAlias:newsitem +path:\-1*2363* which works.

    Regards

    Ismail

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 23, 2010 @ 00:25
    Aaron Powell
    0

    Use the GatheringNodeData event and split the comma separated string into a space separated string then you can query on the ID exactly

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 26, 2010 @ 09:00
    Ismail Mayat
    0

    @slace,

    Ah good point with the gatheringnodedata event for now im using raw query which is a nice little gem you have included into examine api #h5yr!

    Regards

    Ismail

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 27, 2010 @ 00:08
  • Danny 49 posts 104 karma points
    Nov 30, 2010 @ 23:25
    Danny
    0

    Hey folks, I did as slace suggested--split the path string into a space separated string in the GatheringNodeData event. Using Luke I can confirm that the data is indeed split.  For ex:  "-1 1179 1183 1355 1271"

    However I am still unable to directly search on a node id.  Can anyone confirm that this actually works.

  • Danny 49 posts 104 karma points
    Dec 01, 2010 @ 00:04
    Danny
    0

    Update:  I guess that maybe because path is a system controlled field simply replacing the comma with a space doesn't work well.  As shown in my example above, it still shows up in Luke as one long string, but without the commas.

    What I did was to simply add a new field to search on in the ExamineEvents_GatheringNodeData that contains the path with spaces instead of commas and it works like a champ now! 

    e.Fields.Add("searchablePath",e.Fields["path"].Replace(',',' '));
  • Comment author was deleted

    Sep 16, 2013 @ 19:24

    Hey this help me.  Cheers!

  • Chris Roberts 74 posts 106 karma points c-trib
    Aug 27, 2014 @ 12:31
    Chris Roberts
    0

    I know this is an old topic, but I wonder if someone can help.

    I'm trying to implement something like the suggestions here, but I don't seem to have a 'Then' method available to me?! Has this been removed in a more recent release of Examine?

    Any pointers would be appreciated.

    Thanks,
    - Chris

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Aug 27, 2014 @ 15:13
    Ismail Mayat
    0

    Chris,

    What do you mean by then method? Can you paste some code please.

    Regards

    Ismail

  • Chris Roberts 74 posts 106 karma points c-trib
    Aug 27, 2014 @ 15:25
    Chris Roberts
    0

    Hi,

    I was referring to one of the examples above...

    var provider =ExamineManager.Instance.SearchProviderCollection[providerName];

    var query =provider.CreateSearchCriteria(IndexTypes.Content);

     

                        query.NodeTypeAlias(nodeTypeAlias).And().Field("path","-1".MultipleCharacterWildcard().

                           Then(parentNode.ToString().MultipleCharacterWildcard().Value)).

                           And().OrderByDescending(sortField);

     

    var results = provider.Search(query);

    Thanks,

    - Chris

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Aug 27, 2014 @ 17:17
    Ismail Mayat
    0

    Chris,

    Not sure where you copied that example from but I have never seen then? However change the then to and that should fix it?

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft