Skip to content
Permalink
Browse files

Lucene / index reader are usually closed (#4016)

  • Loading branch information
cmangeat authored and fxprunayre committed Dec 6, 2019
1 parent 280b54b commit 35dc9559d75069a4a6670151afdf088c6d1522a9
@@ -1497,13 +1497,11 @@ private void computeQuery(ServiceContext srvContext, Element request, ServiceCon
_query = new LuceneQueryBuilder(_luceneConfig, _tokenizedFieldSet, SearchManager.getAnalyzer(_language.analyzerLanguage, true), _language.presentationLanguage).build(luceneQueryInput);
LOGGER.debug("Lucene query: {}", _query);


_query = appendPortalFilter(_query, _luceneConfig);


try {

try (IndexAndTaxonomy indexReader = _sm.getIndexReader(_language.presentationLanguage, _versionToken)) {
// Rewrite the drilldown query to a query that can be used by the search logger
_loggerQuery = _query.rewrite(_sm.getIndexReader(_language.presentationLanguage, _versionToken).indexReader);
_loggerQuery = _query.rewrite(indexReader.indexReader);
//if(LOGGER.isDebugEnabled()) LOGGER.debug("Rewritten Lucene query: {}", _loggerQuery);
//System.out.println("** rewritten:\n"+ rw);
} catch (Throwable x) {
@@ -550,9 +550,9 @@ private FieldMapper getFieldMapper() {
Log.debug(Geonet.CSW_SEARCH, "Records matched : " + numHits);
}

try {
// Rewrite the drilldown query to a query that can be used by the search logger
Query loggerQuery = _query.rewrite(sm.getIndexReader(_lang.presentationLanguage, _searchToken).indexReader);
try (IndexAndTaxonomy indexReader = sm.getIndexReader(_lang.presentationLanguage, _searchToken)) {
// Rewrite the drilldown query to a query that can be used by the search logger;
Query loggerQuery = _query.rewrite(indexReader.indexReader);
LuceneSearcher.logSearch(context, config, loggerQuery, numHits, _sort, geomWkt, sm);
} catch (Throwable x) {
Log.warning(Geonet.SEARCH_ENGINE, "Error rewriting Lucene query: " + _query);

0 comments on commit 35dc955

Please sign in to comment.
You can’t perform that action at this time.