cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with Lucene and setLimit/setLimitBy

alr
Champ in-the-making
Champ in-the-making
Hello,

I am currently investigating a problem, where I want to limit the amount of returned results, when performing (and sorting) a lucene search. This is what I do in the source:


SearchParameters sp = new SearchParameters();
sp.addStore(storeRef);
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setLimitBy(LimitBy.FINAL_SIZE);
sp.setLimit(limit);
sp.addSort(sortField, sortAscending);
sp.setQuery(searchString);

ResultSet resultSet = searchService.query(sp);
List<NodeRef> refs = resultSet.getNodeRefs();
       
if (logger.isDebugEnabled()) {
    ResultSetMetaData metaData = resultSet.getResultSetMetaData();
    logger.debug("Search has been limited by " + metaData.getLimitedBy() + ". # of results: " + refs.size());
    logger.debug("SP GetLimit: " + metaData.getSearchParameters().getLimit() + " and limitby " + metaData.getSearchParameters().getLimitBy());
}

Now this is the logger output:

16:48:07,330 User:admin DEBUG [alfresco.search.MySearchImpl] Search has been limited by UNLIMITED. # of results: 108
16:48:07,330 User:admin DEBUG [alfresco.search.MySearchImpl] SP GetLimit: 101 and limitby FINAL_SIZE

So, somehow, my limit settings are completely ignored. I get 108 results returned. In case you wonder, why I set the limit to 101, take a look at org.alfresco.service.cmr.search.ResultSetMetaData, where is written in the comments, that searches for an amount lower than 100, might return LimitBy.UNLIMITED. However in this case the search does it as well (sorting works btw).

So, is there anything I am overlooking right now, or didn't I parse the ResultSet correctly? Do I need to access filtered results in another way?

I am using Alfresco Labs 3b, btw.

Thanks for the help!


–Alexander
3 REPLIES 3

rivarola
Champ on-the-rise
Champ on-the-rise
Hi,

If you can set a breakpoint in the ACLEntryAfterInvocationProvider class, it seems there are strange things done in the decide method that accepts a ResultSet as last argument.

alr
Champ in-the-making
Champ in-the-making
Hi

Setting a breakpoint there does not result in any break. I set the breakpoint at the beginning of the

private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config,
            ResultSet returnedObject) throws AccessDeniedException

Method. The only on referring ResultSet as parameter.

I am currently calling that particular search operation from a Trigger - could that be a problem?


Regards,
  Alexander

rivarola
Champ on-the-rise
Champ on-the-rise
Hi,

What do you mean by Trigger ? Are you using searchService will an upper S or lower s ?