
com.jaeksoft.searchlib.index.DocSetHitCacheKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opensearchserver Show documentation
Show all versions of opensearchserver Show documentation
OpenSearchServer is a powerful, enterprise-class, search engine program. Using the web user interface,
the crawlers (web, file, database, ...) and the REST/RESTFul API you will be able to integrate quickly and
easily advanced full-text search capabilities in your application. OpenSearchServer runs on Windows and
Linux/Unix/BSD.
/**
* License Agreement for OpenSearchServer
*
* Copyright (C) 2008-2014 Emmanuel Keller / Jaeksoft
*
* http://www.open-search-server.com
*
* This file is part of OpenSearchServer.
*
* OpenSearchServer is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenSearchServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenSearchServer.
* If not, see .
**/
package com.jaeksoft.searchlib.index;
import java.io.IOException;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.search.Query;
import com.jaeksoft.searchlib.SearchLibException;
import com.jaeksoft.searchlib.analysis.PerFieldAnalyzer;
import com.jaeksoft.searchlib.filter.FilterList;
import com.jaeksoft.searchlib.filter.FilterListCacheKey;
import com.jaeksoft.searchlib.function.expression.SyntaxError;
import com.jaeksoft.searchlib.geo.GeoParameters;
import com.jaeksoft.searchlib.query.ParseException;
import com.jaeksoft.searchlib.request.AbstractSearchRequest;
import com.jaeksoft.searchlib.request.BoostQuery;
import com.jaeksoft.searchlib.request.SearchFilterRequest;
import com.jaeksoft.searchlib.schema.SchemaField;
import com.jaeksoft.searchlib.scoring.AdvancedScore;
public class DocSetHitCacheKey implements Comparable {
private final String query;
private final Boolean forFilterHits;
private final Boolean isScoreRequired;
private final Boolean isDistanceRequired;
private final Boolean isDocIdRequired;
private final FilterListCacheKey filterListCacheKey;
private final String boostQueryCacheKey;
private final String advancedScoreCacheKey;
private final String geoParametersCacheKey;
public DocSetHitCacheKey(SchemaField defaultField, Analyzer analyzer,
Query query, boolean isScoreRequired, boolean isDistanceRequired,
GeoParameters geoParameters, FilterList filterList,
AdvancedScore advancedScore, boolean isDocIdRequired,
BoostQuery[] boostQueries, AbstractSearchRequest request)
throws ParseException, SyntaxError, SearchLibException, IOException {
this.query = query == null ? "" : query.toString();
this.isScoreRequired = isScoreRequired;
this.isDistanceRequired = isDistanceRequired;
this.isDocIdRequired = isDocIdRequired;
this.forFilterHits = request instanceof SearchFilterRequest;
filterListCacheKey = new FilterListCacheKey(filterList, defaultField,
analyzer, request);
boostQueryCacheKey = BoostQuery.getCacheKey(boostQueries);
advancedScoreCacheKey = AdvancedScore.getCacheKey(advancedScore);
geoParametersCacheKey = GeoParameters.getCacheKey(geoParameters);
}
public DocSetHitCacheKey(AbstractSearchRequest searchRequest,
SchemaField defaultField, PerFieldAnalyzer analyzer)
throws ParseException, SyntaxError, SearchLibException, IOException {
this(defaultField, analyzer, searchRequest.getQuery(), searchRequest
.isScoreRequired(), searchRequest.isDistanceRequired(),
searchRequest.getGeoParameters(),
searchRequest.getFilterList(),
searchRequest.getAdvancedScore(), searchRequest
.isDocIdRequired(), searchRequest.getBoostingQueries(),
searchRequest);
}
@Override
public int compareTo(DocSetHitCacheKey r) {
int c;
if ((c = query.compareTo(r.query)) != 0)
return c;
if ((c = forFilterHits.compareTo(r.forFilterHits)) != 0)
return c;
if ((c = isScoreRequired.compareTo(r.isScoreRequired)) != 0)
return c;
if ((c = isDistanceRequired.compareTo(r.isDistanceRequired)) != 0)
return c;
if ((c = isDocIdRequired.compareTo(r.isDocIdRequired)) != 0)
return c;
if ((c = filterListCacheKey.compareTo(r.filterListCacheKey)) != 0)
return c;
if ((c = boostQueryCacheKey.compareTo(r.boostQueryCacheKey)) != 0)
return c;
if ((c = advancedScoreCacheKey.compareTo(r.advancedScoreCacheKey)) != 0)
return c;
if ((c = geoParametersCacheKey.compareTo(r.geoParametersCacheKey)) != 0)
return c;
return 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy