cancel
Showing results for 
Search instead for 
Did you mean: 

SearchService.selectNodes(...) example

eolith
Champ on-the-rise
Champ on-the-rise
Hello,

I'm trying to find sample code using the "selectNodes" method from SearchService, but I haven't found anything at all.

I want to do a attribute-based search with the documents contained in a specified folder, and I think this method could be useful for this purpose.

The "selectNodes" method has 5 params:

NodeRef contextNodeRef - the context node for relative expressions etc
String xpath - the xpath string to evaluate
QueryParameterDefinition[] parameters - parameters to bind in to the xpath expression
NamespacePrefixResolver namespacePrefixResolver - prefix to namespace mappings
boolean followAllParentLinks - if false ".." follows only the primary parent links, if true it follows all

contextNodeRef -> my folder nodeRef, I guess… ??
xpath -> "/" for current space?
parameters -> search parameters? I don't know how to create "QueryParameterDefinition" objects…
namespacePrefixResolver -> ????
followAllParentLinks -> I don't know what it means…

Thanks for your help.
1 REPLY 1

mrksjs
Champ on-the-rise
Champ on-the-rise
well, this might be late

<code>
   // you'll need to inject these two services
   // dont forget to write setter methods for them
   SearchService searchService = … ;
   Repository repository = … ;
   
   // get nodeRef of company home
   NodeRef home = repository.getCompanyHome();
   
   // namespacePrefixResolver can't be null, thats how you get it, for custom models you need to enhance the namespaces
   DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
   namespacePrefixResolver.registerNamespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI);
   namespacePrefixResolver.registerNamespace(NamespaceService.APP_MODEL_PREFIX, NamespaceService.APP_MODEL_1_0_URI);
   namespacePrefixResolver.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI);

   // should give you a set with all nodes under 'company home '
   List<NodeRef> result =  searchService.selectNodes(home, "*", null, namespacePrefixResolver, false); 
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.