diff --git a/htroot/HostBrowser.java b/htroot/HostBrowser.java index 522b2d7b4..ddf4aa27e 100644 --- a/htroot/HostBrowser.java +++ b/htroot/HostBrowser.java @@ -265,19 +265,29 @@ public class HostBrowser { if (!fulltext.getDefaultConfiguration().contains(facetfield)) continue; ff.add(csf.getSolrFieldName()); } + // add also vocabulary counters + Map> vocabularyFacet = sb.index.fulltext().getDefaultConnector().getFacets(CollectionSchema.vocabularies_sxt.getSolrFieldName() + ":[* TO *]", 100, CollectionSchema.vocabularies_sxt.getSolrFieldName()); + if (vocabularyFacet.size() > 0) { + Collection vocnames = vocabularyFacet.values().iterator().next().keyList(true); + for (String vocname: vocnames) { + ff.add(CollectionSchema.VOCABULARY_PREFIX + vocname + CollectionSchema.VOCABULARY_LOGCOUNT_SUFFIX); + ff.add(CollectionSchema.VOCABULARY_PREFIX + vocname + CollectionSchema.VOCABULARY_LOGCOUNTS_SUFFIX); + } + } + // list the facets String[] facetfields = ff.toArray(new String[ff.size()]); Map> facets = fulltext.getDefaultConnector().getFacets(CollectionSchema.host_s.getSolrFieldName() + ":\"" + host + "\"", 100, facetfields); int fc = 0; - for (String facetfield: facetfields) { - ReversibleScoreMap facetfieldmap = facets.get(facetfield); + for (Map.Entry> facetentry: facets.entrySet()) { + ReversibleScoreMap facetfieldmap = facetentry.getValue(); if (facetfieldmap.size() == 0) continue; TreeMap statMap = new TreeMap<>(); for (String k: facetfieldmap) statMap.put(Long.parseLong(k), facetfieldmap.get(k)); - prop.put("hostanalysis_facets_" + fc + "_facetname", facetfield); + prop.put("hostanalysis_facets_" + fc + "_facetname", facetentry.getKey()); int c = 0; for (Entry entry: statMap.entrySet()) { prop.put("hostanalysis_facets_" + fc + "_facet_" + c + "_key", entry.getKey()); prop.put("hostanalysis_facets_" + fc + "_facet_" + c + "_count", entry.getValue()); - prop.put("hostanalysis_facets_" + fc + "_facet_" + c + "_a", "http://localhost:" + sb.getConfigInt("port", 8090) + "/solr/collection1/select?q=host_s:" + host + " AND " + facetfield + ":" + entry.getKey() + "&defType=edismax&start=0&rows=1000&fl=sku,crawldepth_i"); + prop.put("hostanalysis_facets_" + fc + "_facet_" + c + "_a", "http://localhost:" + sb.getConfigInt("port", 8090) + "/solr/collection1/select?q=host_s:" + host + " AND " + facetentry.getKey() + ":" + entry.getKey() + "&defType=edismax&start=0&rows=1000&fl=sku,crawldepth_i"); c++; } prop.put("hostanalysis_facets_" + fc + "_facet", c); diff --git a/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java index b9db0e3c7..adc99ba4b 100644 --- a/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/AbstractSolrConnector.java @@ -27,6 +27,7 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -462,7 +463,7 @@ public abstract class AbstractSolrConnector implements SolrConnector { // construct raw query final SolrQuery params = new SolrQuery(); //params.setQuery(CollectionSchema.id.getSolrFieldName() + ":\"" + id + "\""); - String q = "{!raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id; + String q = "{!cache=false raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id; params.setQuery(q); params.setRows(1); params.setStart(0); @@ -511,7 +512,7 @@ public abstract class AbstractSolrConnector implements SolrConnector { * @throws IOException */ @Override - public Map> getFacets(String query, int maxresults, final String ... fields) throws IOException { + public LinkedHashMap> getFacets(String query, int maxresults, final String ... fields) throws IOException { // construct query assert fields.length > 0; final SolrQuery params = new SolrQuery(); @@ -530,7 +531,7 @@ public abstract class AbstractSolrConnector implements SolrConnector { // query the server QueryResponse rsp = getResponseByParams(params); - Map> facets = new HashMap>(fields.length); + LinkedHashMap> facets = new LinkedHashMap>(fields.length); for (String field: fields) { FacetField facet = rsp.getFacetField(field); ReversibleScoreMap result = new ClusteredScoreMap(UTF8.insensitiveUTF8Comparator); @@ -548,7 +549,7 @@ public abstract class AbstractSolrConnector implements SolrConnector { final SolrQuery query = new SolrQuery(); // construct query StringBuilder sb = new StringBuilder(23); - sb.append("{!raw f=").append(CollectionSchema.id.getSolrFieldName()).append('}').append(id); + sb.append("{!cache=false raw f=").append(CollectionSchema.id.getSolrFieldName()).append('}').append(id); query.setQuery(sb.toString()); //query.setQuery("*:*"); //query.addFilterQuery(sb.toString()); diff --git a/source/net/yacy/cora/federate/solr/connector/CachedSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/CachedSolrConnector.java index 2147fca85..4036876d2 100644 --- a/source/net/yacy/cora/federate/solr/connector/CachedSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/CachedSolrConnector.java @@ -22,7 +22,7 @@ package net.yacy.cora.federate.solr.connector; import java.io.IOException; import java.util.Collection; -import java.util.Map; +import java.util.LinkedHashMap; import net.yacy.cora.sorting.ReversibleScoreMap; import net.yacy.cora.storage.ARC; @@ -254,7 +254,7 @@ public class CachedSolrConnector extends AbstractSolrConnector implements SolrCo } @Override - public Map> getFacets(final String query, final int maxresults, final String ... fields) throws IOException { + public LinkedHashMap> getFacets(final String query, final int maxresults, final String ... fields) throws IOException { return this.solr.getFacets(query, maxresults, fields); } diff --git a/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java index f6c91203a..984819beb 100644 --- a/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java @@ -25,7 +25,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.BlockingQueue; import net.yacy.cora.sorting.ReversibleScoreMap; @@ -354,7 +353,7 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector { } @Override - public Map> getFacets(String query, int maxresults, String... fields) throws IOException { + public LinkedHashMap> getFacets(String query, int maxresults, String... fields) throws IOException { commitDocBuffer(); return this.connector.getFacets(query, maxresults, fields); } diff --git a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java index 25a69bbeb..1bd781a80 100644 --- a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java @@ -421,7 +421,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo int responseCount = 0; DocListSearcher docListSearcher = null; try { - docListSearcher = new DocListSearcher("{!raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id, null, 0, 1, CollectionSchema.id.getSolrFieldName(), CollectionSchema.load_date_dt.getSolrFieldName()); + docListSearcher = new DocListSearcher("{!cache=false raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id, null, 0, 1, CollectionSchema.id.getSolrFieldName(), CollectionSchema.load_date_dt.getSolrFieldName()); responseCount = docListSearcher.response.size(); if (responseCount == 0) return null; SolrIndexSearcher searcher = docListSearcher.request.getSearcher(); diff --git a/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java index 4220f50db..6c65b9202 100644 --- a/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/MirrorSolrConnector.java @@ -22,7 +22,7 @@ package net.yacy.cora.federate.solr.connector; import java.io.IOException; import java.util.Collection; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.atomic.AtomicLong; @@ -383,16 +383,16 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo } @Override - public Map> getFacets(final String query, final int maxresults, final String ... fields) throws IOException { - if (this.solr0 == null && this.solr1 == null) return new HashMap>(0); + public LinkedHashMap> getFacets(final String query, final int maxresults, final String ... fields) throws IOException { + if (this.solr0 == null && this.solr1 == null) return new LinkedHashMap>(0); if (this.solr0 != null && this.solr1 == null) { return this.solr0.getFacets(query, maxresults, fields); } if (this.solr1 != null && this.solr0 == null) { return this.solr1.getFacets(query, maxresults, fields); } - Map> facets0 = this.solr0.getFacets(query, maxresults, fields); - Map> facets1 = this.solr1.getFacets(query, maxresults, fields); + LinkedHashMap> facets0 = this.solr0.getFacets(query, maxresults, fields); + LinkedHashMap> facets1 = this.solr1.getFacets(query, maxresults, fields); for (Map.Entry> facet0: facets0.entrySet()) { ReversibleScoreMap facet1 = facets1.remove(facet0.getKey()); if (facet1 == null) continue; diff --git a/source/net/yacy/cora/federate/solr/connector/SolrConnector.java b/source/net/yacy/cora/federate/solr/connector/SolrConnector.java index 527668456..4fb212bc3 100644 --- a/source/net/yacy/cora/federate/solr/connector/SolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/SolrConnector.java @@ -22,8 +22,8 @@ package net.yacy.cora.federate.solr.connector; import java.io.IOException; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.BlockingQueue; import net.yacy.cora.sorting.ReversibleScoreMap; @@ -221,7 +221,7 @@ public interface SolrConnector extends Iterable /* Iterable of document * @return a map with key = facet field name, value = an ordered map of field values for that field * @throws IOException */ - public Map> getFacets(String query, int maxresults, final String ... fields) throws IOException; + public LinkedHashMap> getFacets(String query, int maxresults, final String ... fields) throws IOException; /** * Get results from a solr query as a stream of documents.