Good morning. I have a task to make a request that would find all the documents of a certain type. After receiving the result, I need to display the fields of all found documents in the table. How can I do that? Thanks for answers.
Asked
Active
Viewed 348 times
-1
-
2Welcome to SO, what did you try? Do you call the REST-API? Please show us your sourcecode. – cSteusloff Apr 11 '18 at 06:27
-
I'm trying to write a web script, but as soon as it came to writing a query there were problems) I recently in alfresco and Java so there are difficulties in the simplest situations – Kun Aguero Apr 11 '18 at 07:01
-
which sourcecode to show? – Kun Aguero Apr 11 '18 at 07:02
-
1What problems do you have with writing the query? Please [edit] your question and include the relevant part of your model and the query you try. – Apr 11 '18 at 07:20
2 Answers
2
To retrieve all documents of a certain type you can use Lucene query, this is a working example of query to get all nodes with type ipt:delegation
using java.
String query = "TYPE:\"ipt:delegation\"";
SearchParameters sp = new SearchParameters();
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
sp.addStore(storeRef);
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(query);
ResultSet results = null;
try {
results = searchService().query(sp);
for (ResultSetRow row : results) {
NodeRef nodeRef = row.getNodeRef();
// do your work -
}
}
And to retrieve document fields you can use nodeService.getProperties(nodeRef)
.

Oussama Werfelli
- 513
- 3
- 14
-
Yes, Exact. @Kun Aguero now you can get all the nodes of the particular type as Oussama has explained. – Vikash Patel Apr 13 '18 at 04:59