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
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]}
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.
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.
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!
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?
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?
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
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
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
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
In answer to me question for now i used rawquery namely +__NodeTypeAlias:newsitem +path:\-1*2363* which works.
Regards
Ismail
Use the GatheringNodeData event and split the comma separated string into a space separated string then you can query on the ID exactly
@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
I blogged it here: http://farmcode.org/post/2010/09/22/Searching-Multi-Node-Tree-Picker-data-(or-any-collection)-with-Examine.aspx
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.
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!
Comment author was deleted
Hey this help me. Cheers!
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
Chris,
What do you mean by then method? Can you paste some code please.
Regards
Ismail
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
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
is working on a reply...