From 592adf7ccbc01302931268833e9de638ed8cd273 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sat, 2 Feb 2013 07:21:18 +0100 Subject: [PATCH] fix for domain navigation --- source/net/yacy/search/query/QueryParams.java | 14 ++++++++++++-- source/net/yacy/search/query/SearchEvent.java | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.java index 62bba6e30..753be5ec8 100644 --- a/source/net/yacy/search/query/QueryParams.java +++ b/source/net/yacy/search/query/QueryParams.java @@ -128,7 +128,7 @@ public final class QueryParams { public final RankingProfile ranking; private final Segment indexSegment; public final String clienthost; // this is the client host that starts the query, not a site operator - private final String nav_sitehost; // this is a domain name which is used to navigate to that host + public final String nav_sitehost; // this is a domain name which is used to navigate to that host public final String nav_sitehash; // this is a domain hash, 6 bytes long or null protected final Set siteexcludes; // set of domain hashes that are excluded if not included by sitehash public final String author; @@ -145,6 +145,7 @@ public final class QueryParams { protected double lat, lon, radius; public List facetfields; public int maxfacets; + private SolrQuery cachedQuery; // the following values are filled during the search process as statistics for the search public final AtomicInteger local_rwi_available; // the number of hits generated/ranked by the local search in rwi index @@ -212,6 +213,7 @@ public final class QueryParams { this.facetfields = new ArrayList(); for (String f: defaultfacetfields) facetfields.add(f); for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX); this.maxfacets = defaultmaxfacets; + this.cachedQuery = null; } public QueryParams( @@ -313,6 +315,7 @@ public final class QueryParams { this.facetfields = new ArrayList(); for (String f: defaultfacetfields) facetfields.add(f); for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX); this.maxfacets = defaultmaxfacets; + this.cachedQuery = null; } private double kmNormal = 100.d; // 100 =ca 40000.d / 360.d == 111.11 - if lat/lon is multiplied with this, rounded and diveded by this, the location is normalized to a 1km grid @@ -431,6 +434,10 @@ public final class QueryParams { } public SolrQuery solrQuery() { + if (this.cachedQuery != null) { + this.cachedQuery.setStart(this.offset); + return this.cachedQuery; + } if (this.queryGoal.getIncludeStrings().size() == 0) return null; // construct query final SolrQuery params = new SolrQuery(); @@ -519,10 +526,13 @@ public final class QueryParams { params.setSortField(YaCySchema.last_modified.getSolrFieldName(), ORDER.desc); } } - if (fq.length() > 0) params.setFilterQueries(fq.substring(5)); + if (fq.length() > 0) { + params.setFilterQueries(fq.substring(5)); + } // prepare result Log.logInfo("Protocol", "SOLR QUERY: " + params.toString()); + this.cachedQuery = params; return params; } diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.java index bc95a905a..9afcd9b79 100644 --- a/source/net/yacy/search/query/SearchEvent.java +++ b/source/net/yacy/search/query/SearchEvent.java @@ -599,7 +599,7 @@ public final class SearchEvent { } } else { // filter out all domains that do not match with the site constraint - if (!hosthash.equals(this.query.nav_sitehash)) continue pollloop; + if (iEntry.url().getHost().indexOf(this.query.nav_sitehost) < 0) continue pollloop; } // finally extend the double-check and insert result to stack