I need to be able to search for publish nodes based on a property. For example, if I have an Employee document type with the property FirstName, how can I search for nodes based on the FirstName property using the API?
Either iterating (but don't think that's a good idea performance-wise or you could use the available umbraco.library functions (and which are available from both .net code and from xslt
/// <summary>
/// Queries the umbraco Xml cache with the specified Xpath query
/// </summary>
/// <param name="xpathQuery">The XPath query</param>
/// <returns>Returns nodes matching the xpath query as a XpathNodeIterator</returns>
public static XPathNodeIterator GetXmlNodeByXPath(string xpathQuery)
{
XPathNavigator xp = content.Instance.XmlContent.CreateNavigator();
return xp.Select(xpathQuery);
}
In your case, xpath expression would be something along the lines of:
Lucene is by default not indexing the properties if a node. So you have to implement BeforeIndexing Handlers (I did this before implementing SS4U) and an own search interface to Lucene. IMHO not a simple way.
And SS4U is really fast (much faster than Lucene in our tests for a site with 1000 nodes), cause the object model is in memory as the xml is. Also you can set startnodes and define which doctypes and properties to search.
But as Dirk says: there are several options. It depends on things like experience with xpath/xslt or .Net and the site size and the structure and so on...
Also: if you don't need to access via api you can also take xsltsearch from doug, etc.
Search Nodes by Property
I need to be able to search for publish nodes based on a property. For example, if I have an Employee document type with the property FirstName, how can I search for nodes based on the FirstName property using the API?
Thanks.
iterating through the umbraco.presentation.nodefactory...
You also can use the simple search 4 umbraco.
if you have questions just contact me via th |at| thoehler |dot| com
Thomas
Either iterating (but don't think that's a good idea performance-wise or you could use the available umbraco.library functions (and which are available from both .net code and from xslt
In your case, xpath expression would be something along the lines of:
Hope this helps.
Regards,
/Dirk
Oh, and another option is to use the search functionality available through Lucene.net (which is also available OOB)
If you need some samples (it's bit more complicated than using the library functions), shoot me an email at dirk at netaddicts dot be
Btw: Thomas' simple search 4 umbraco is also a perfect candidate, i'm merely summing up the possibilities.
Cheers,
/Dirk
Lucene is by default not indexing the properties if a node. So you have to implement BeforeIndexing Handlers (I did this before implementing SS4U) and an own search interface to Lucene. IMHO not a simple way.
And SS4U is really fast (much faster than Lucene in our tests for a site with 1000 nodes), cause the object model is in memory as the xml is. Also you can set startnodes and define which doctypes and properties to search.
But as Dirk says: there are several options. It depends on things like experience with xpath/xslt or .Net and the site size and the structure and so on...
Also: if you don't need to access via api you can also take xsltsearch from doug, etc.
Hope that I did not confuse you to much ;-)
Thomas
oh, thanks for refreshing my mind, i have used those event handlers, that is why i was thinking it's standard functionality.! it's not!
cheers,
/Dirk
Thanks!
is working on a reply...