cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a document from his UUID ?

sam69
Champ in-the-making
Champ in-the-making
Hi,
It look simple, but I can't make it work..
I did that :


Query query = new Query(Constants.QUERY_LANG_LUCENE, "ID:"+content.getNode().getUuid()+"\"");

QueryResult result2 = getWebServiceFactory().getRepositoryService().query(STORE, query, true);
ResultSet resultSet = result2.getResultSet();

And the resultSet is empty…

Is it the good way to get the properties of a document when we know his UUID ?

Thanks in advance for your help !

Cheers,

Sam
4 REPLIES 4

fchevance
Champ in-the-making
Champ in-the-making
Hi,

I would do like this:


RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();

Node myNode = null;
Reference reference = new Reference(STORE, uuid, null);
Predicate predicate = new Predicate(new Reference[]{reference}, null, null);
Node[] nodes = repositoryService.get(predicate);

// Get the node
myNode = nodes[0];

// Get it properties
NamedValue[] columns = myNode.getProperties();

Fred

sam69
Champ in-the-making
Champ in-the-making
Thanks a lot Fred !
I am so stupid, I already did that several times 😉

sergio
Champ in-the-making
Champ in-the-making
Hi all.

Why does the following code

Query query = new Query(Constants.QUERY_LANG_LUCENE, "ID:"+content.getNode().getUuid()+"\"");

QueryResult result2 = getWebServiceFactory().getRepositoryService().query(STORE, query, true);
ResultSet resultSet = result2.getResultSet();

not work?

Is there any difference between the uuid and id node?

I tried the following code, too:

String path = "ID(\"e8bee600-8470-11db-85c2-01d4040f47aa\")";

and the result of the query is not null but it retrieves more than one node.

Why?

All the best,

Sergio

andy
Champ on-the-rise
Champ on-the-rise
Hi

The property uuid is just that.

The ID field is the untokenised node ref. The index will contain duplicates for folders ….. that is how the index works… it has some additional entries for folders.

To use ID and get one result ….


+ID:"id" -ISCONTAINER:T

Regards

Andy