cancel
Showing results for 
Search instead for 
Did you mean: 

Perform count(*) with Lucene's query

alf_kin
Champ in-the-making
Champ in-the-making
Hi guys,
I'm facing with a hard job to do. I have to COUNT all the documents that match a specific query. The number of matching documents is around 100'000. My searchparameter is composed in this way:

                SearchParameters sp = new SearchParameters();
      sp.addStore(Repository.getStoreRef());
      sp.setLanguage(SearchService.LANGUAGE_LUCENE);
      sp.setQuery(finalQuery);
      sp.setMaxPermissionChecks(600*1000);
      sp.setMaxPermissionCheckTimeMillis(600*1000);
      sp.setLimitBy(LimitBy.UNLIMITED);
      sp.setLimit(0);
      sp.setMaxItems(-1);


This kind of query takes about 600000 ms to finish !!!(sometimes this time is not enough and resultset is incomplete Smiley Indifferent). At the end of query i get resultset.length value. I'm using java-backend webscript to do this task. Are there other ways to go to reach the goal???

I'm groping into darkness…

thanks.
a.   
1 REPLY 1

alf_kin
Champ in-the-making
Champ in-the-making
Googling i have found this snipset


TopScoreDocCollector collector = TopScoreDocCollector.create(10, true);
searcher.search(query, collector);
TopDocs topDocs = collector.topDocs();
int numResults = collector.getTotalHits();


which should enable me to count document whitout take all documents informations. But now the question is: can i use pure lucene-api in Alfresco webscript??
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.