08-18-2020 06:29 PM
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.
08-18-2020 06:51 PM
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.
08-19-2020 07:10 AM
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.
08-19-2020 09:58 AM
Explore our Alfresco products with the links below. Use labels to filter content by product module.