It is possible to do the search if you want to. Here are some pieces from an example of how i solved it. I have a page that works as a search/display for certain resources and the page calls itself with a querystring "?q=something" when the user searches in the search field. But to start with, it shows them all..
1) Start of with initializing the search query, which might be empty in your case the first time someone enters the page
<% String searchTerm = ""; String searchPath = "put the root-search-path here in the way you prefer" boolean searched = true; // If there has been a search or not if(slingRequest.getRequestParameter("q") != null ){ searchTerm = slingRequest.getRequestParameter("q").getString("UTF-8"); //Get the queryparameter (q in this case) }else{ searched = false; } searchTerm = "*" + searchTerm + "*"; //Add some wildcards if you like %>
2) Initialize a search with the searchterm fetched above
<% HashMap<String, String> map = new HashMap<String, String>(); map.put("path", searchPath); map.put("type", "nt:unstructured"); map.put("property", "sling:resourceType"); map.put("property.value", "cq:page"); map.put("group.p.or", "true"); // combine this group with OR map.put("group.1_fulltext", fulltextSearchTerm); map.put("group.1_fulltext.relPath", "@yourNode/jcr:description"); map.put("group.2_fulltext", fulltextSearchTerm); map.put("group.2_fulltext.relPath", "@yourNode/jcr:title"); map.put("orderby","SOME_ORDER_CRITERIA"); map.put("p.limit", "LIMIT_IF_YOU_WANT"); // same as query.setHitsPerPage(20) QueryBuilder builder = resource.getResourceResolver().adaptTo(QueryBuilder.class); Session session = resource.getResourceResolver().adaptTo(Session.class); Query query = builder.createQuery(PredicateGroup.create(map), session); SearchResult result = query.getResult(); // Do the query List<Hit> hits = result.getHits(); // Get all the hits int nrOfResults = hits.size(); //Get the number of results %>
3) Loop through your results and display/present them in the way you like:
<% for (Hit hit: hits) { Resource myJob = hit.getResource(); if(myJob != null){ //Do something with your resource and present it nicely } } %>
Now this was just a short example of how to solve this and you might have to modify the queries and such according to you needs.
In my query I had a somewhat complicated node structure and I searched both the description and title on a node located unded the page itself.
You could of course incorporate some kind of search / filtering into your own component that extends the OOB list component. It depends on what you prefer. But somehow the example of a search component page seems a bit simpler if you are going to do a free text search amongst the properties in a resource . Hope things will work out!
/Johan