@ -30,7 +30,7 @@ import java.util.ArrayList;
import java.util.Collection ;
import java.util.Collection ;
import java.util.HashMap ;
import java.util.HashMap ;
import java.util.Iterator ;
import java.util.Iterator ;
import java.util.Li st;
import java.util.Li nkedHa shSe t;
import java.util.Map ;
import java.util.Map ;
import java.util.Set ;
import java.util.Set ;
import java.util.regex.Pattern ;
import java.util.regex.Pattern ;
@ -38,6 +38,7 @@ import java.util.regex.PatternSyntaxException;
import org.apache.solr.client.solrj.SolrQuery ;
import org.apache.solr.client.solrj.SolrQuery ;
import org.apache.solr.client.solrj.SolrQuery.SortClause ;
import org.apache.solr.client.solrj.SolrQuery.SortClause ;
import org.apache.solr.common.params.FacetParams ;
import net.yacy.cora.document.ASCII ;
import net.yacy.cora.document.ASCII ;
import net.yacy.cora.document.analysis.Classification ;
import net.yacy.cora.document.analysis.Classification ;
@ -119,7 +120,7 @@ public final class QueryParams {
public final String userAgent ;
public final String userAgent ;
protected boolean filterfailurls , filterscannerfail ;
protected boolean filterfailurls , filterscannerfail ;
protected double lat , lon , radius ;
protected double lat , lon , radius ;
public Li st< String > facetfields ;
public Li nkedHa shSe t< String > facetfields ;
public int maxfacets ;
public int maxfacets ;
private SolrQuery cachedQuery ;
private SolrQuery cachedQuery ;
private CollectionConfiguration solrSchema ;
private CollectionConfiguration solrSchema ;
@ -165,7 +166,7 @@ public final class QueryParams {
this . lat = 0.0d ;
this . lat = 0.0d ;
this . lon = 0.0d ;
this . lon = 0.0d ;
this . radius = 0.0d ;
this . radius = 0.0d ;
this . facetfields = new Array List< String > ( ) ;
this . facetfields = new LinkedHa shSe t< String > ( ) ;
this . solrSchema = indexSegment . fulltext ( ) . getDefaultConfiguration ( ) ;
this . solrSchema = indexSegment . fulltext ( ) . getDefaultConfiguration ( ) ;
for ( CollectionSchema f : defaultfacetfields ) {
for ( CollectionSchema f : defaultfacetfields ) {
@ -266,7 +267,7 @@ public final class QueryParams {
this . lat = Math . floor ( lat * this . kmNormal ) / this . kmNormal ;
this . lat = Math . floor ( lat * this . kmNormal ) / this . kmNormal ;
this . lon = Math . floor ( lon * this . kmNormal ) / this . kmNormal ;
this . lon = Math . floor ( lon * this . kmNormal ) / this . kmNormal ;
this . radius = Math . floor ( radius * this . kmNormal + 1 ) / this . kmNormal ;
this . radius = Math . floor ( radius * this . kmNormal + 1 ) / this . kmNormal ;
this . facetfields = new Array List< String > ( ) ;
this . facetfields = new LinkedHa shSe t< String > ( ) ;
this . solrSchema = indexSegment . fulltext ( ) . getDefaultConfiguration ( ) ;
this . solrSchema = indexSegment . fulltext ( ) . getDefaultConfiguration ( ) ;
for ( CollectionSchema f : defaultfacetfields ) {
for ( CollectionSchema f : defaultfacetfields ) {
@ -376,7 +377,7 @@ public final class QueryParams {
return SetTools . anymatch ( wordhashes , keyhashes ) ;
return SetTools . anymatch ( wordhashes , keyhashes ) ;
}
}
public SolrQuery solrQuery ( ) {
public SolrQuery solrQuery ( boolean getFacets ) {
if ( this . cachedQuery ! = null ) {
if ( this . cachedQuery ! = null ) {
this . cachedQuery . setStart ( this . offset ) ;
this . cachedQuery . setStart ( this . offset ) ;
return this . cachedQuery ;
return this . cachedQuery ;
@ -512,6 +513,21 @@ public final class QueryParams {
params . setFilterQueries ( fq . substring ( 5 ) ) ;
params . setFilterQueries ( fq . substring ( 5 ) ) ;
}
}
params . setStart ( offset ) ;
params . setRows ( itemsPerPage ) ;
// set facet query attributes
if ( getFacets & & this . facetfields . size ( ) > 0 ) {
params . setFacet ( true ) ;
params . setFacetLimit ( this . maxfacets ) ;
params . setFacetSort ( FacetParams . FACET_SORT_COUNT ) ;
for ( String field : this . facetfields ) params . addFacetField ( field ) ;
} else {
params . setFacet ( false ) ;
}
params . setFields ( "*" , "score" ) ; // we need the score for post-ranking
// prepare result
// prepare result
Log . logInfo ( "Protocol" , "SOLR QUERY: " + params . toString ( ) ) ;
Log . logInfo ( "Protocol" , "SOLR QUERY: " + params . toString ( ) ) ;
this . cachedQuery = params ;
this . cachedQuery = params ;