I am trying to reduce the search resullt using lunene query with pagination option.(maxItems and skipCount).
Can any one help me to write a lucene query with pagination option.
You can also use Search V1 Rest API:
Query example:
{ "query": { "query": "+TYPE:\"cm:content\"", "language": "afts" }, "paging": { "maxItems": "25", "skipCount": "10" }, "sort": [{"type":"FIELD", "field":"cm:name", "ascending":"false"}] }
curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' --header 'Authorization: Basic VElDS0VUXzIxYzAzOWMxNjFjYzljMDNmNmNlMzAwYzAyMDY5YTQ2OTQwZmYzZmM=' --data-binary '@paging-sort-query.json' 'http://localhost:8080/alfresco/api/-default-/public/search/versions/1/search'
Alternatively, if you prefer to write your own webscript, Have a look at the WebScript in the post here
var contentType = "cm:content"
var aspectName = "demo:webable"
var query = 'PATH:"/app:company_home/st:sites//*" AND TYPE:"'+contentType+'" AND NOT ASPECT:"'+aspectName+'" AND NOT ASPECT:"cm:lockable"';
var page = { skipCount : 0, maxItems : 1000
}; var searchQuery = { query : query, language : "lucene", page : page }; logger.log("Query for search: "+query) var nodes = search.query(searchQuery);
It searches the repository with paginated options and adds a missing aspect.
you can take reference from the script.
The original poster is clearly using Alfresco 4.2 or earlier, which still supported Alfresco Explorer, so they cannot use v1 ReST API at all, which were only added in Alfresco 5.2.
The suggestion with using JavaScript API in a web script is appropriate - alternative, Java API in a Java-backed web script or any other component where you need the query is also possible. Within the Node Browser, which the OP posted as a screenshot, there is no support for pagination. The query itself can also not be rewritten to use pagination - pagination absolutely requires the use of query-external search parameters.
With regards to using Lucene: This is quite an old and deprecated search query language. In Alfresco 4.x, you can already use Alfresco FTS (AFTS / fts-alfresco) which is the recommended query language for cross-version support, and which also receives performance improvements and new features, such as TMQ. Apart from Alfresco 3.x and earlier versions, Lucene should be avoided.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.