cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] repositoryService.query not returning metadata

mwildam
Champ in-the-making
Champ in-the-making
I searched for a document file (content node) and wanted to get back all the properties of the found node.

But although using
QueryResult qresult = repositoryService.query(spacesStore, query, true);
(last boolean parameter should mean that meta-information is included in the results) I only get the path in the ResultRows after using
ResultSet results = qresult.getResultSet();
ResultSetRow[] rows = results.getRows();
Am I doing something wrong or is it possible that there is a bug?
If this is not working, which other possibility do I have to retrieve all the properties of a node?
8 REPLIES 8

rscottm
Champ in-the-making
Champ in-the-making
I've just had a similar problem.  I was told, in a different forum post, that you can't get properties (at least not custom properties) back from  Lucene search.  What I was told to do (by Alfresco) is to get the node ids out of the result set, & do one-by-one lookups using the NodeService.  I haven't been able to confirm that approach due to other problems.

Hope this helps,
scott

mwildam
Champ in-the-making
Champ in-the-making
What I was told to do (by Alfresco) is to get the node ids out of the result set, & do one-by-one lookups using the NodeService. I haven't been able to confirm that approach due to other problems.

I can confirm this - See http://forums.alfresco.com/en/viewtopic.php?p=83809#p83809

mwildam
Champ in-the-making
Champ in-the-making
But what I really wonder: Why are so many wrong samples cited. I found the sample that is not working at least 5 times and the correct one nowhere.

rscottm
Champ in-the-making
Champ in-the-making
Greetings!

I just stumbled on this in another forum.  Don't use query, use get, as in this snippet:

      RepositoryServiceSoapBindingStub repository = WebServiceFactory.getRepositoryService();

      Query query = new Query(QUERY_LANG_LUCENE, config.getQueryString());

      Node[] nodes = repository.get(new Predicate(null, AlfrescoHelper.getDefaultStore(), query));

This approach works, nodes in the result array have all property values.  Don't know what the performance impact might be, however.

No clue about wrong samples, but quality/quantity of documentation seems to be a general problem for Alfresco. ;-}

best,
scott

mwildam
Champ in-the-making
Champ in-the-making
Thanks, that works better. 🙂

mwildam
Champ in-the-making
Champ in-the-making
Before I was fetching ids and then retrieved node by node as a workaround - for sure your solution is more performant (as a SOAP web service can be performant).

unknown-user
Champ on-the-rise
Champ on-the-rise
Greetings!

I just stumbled on this in another forum.  Don't use query, use get, as in this snippet:

      RepositoryServiceSoapBindingStub repository = WebServiceFactory.getRepositoryService();

      Query query = new Query(QUERY_LANG_LUCENE, config.getQueryString());

      Node[] nodes = repository.get(new Predicate(null, AlfrescoHelper.getDefaultStore(), query));

This approach works, nodes in the result array have all property values.  Don't know what the performance impact might be, however.

No clue about wrong samples, but quality/quantity of documentation seems to be a general problem for Alfresco. ;-}

best,
scott


Where did you find this?  Do you have a complete example?

Thank you

jcustovic
Champ in-the-making
Champ in-the-making
Could somebody explane why this code is working in every case:

Query query = new Query(QUERY_LANG_LUCENE, config.getQueryString());
Node[] nodes = repository.get(new Predicate(null, AlfrescoHelper.getDefaultStore(), query));

And this code in numerous cases don't return all properties:
QueryResult qresult = repositoryService.query(spacesStore, query, true);

??