Make navigators underlaying indexfield name accessible in interface

use interface in declaration and extend facet check to include navigator
field.
pull/93/head
reger 8 years ago
parent 5eb3ee4e20
commit 67f660523b

@ -44,7 +44,7 @@ import net.yacy.peers.graphics.ProfilingGraph;
import net.yacy.search.EventTracker;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.navigator.StringNavigator;
import net.yacy.search.navigator.Navigator;
import net.yacy.search.query.QueryParams;
import net.yacy.search.query.SearchEvent;
import net.yacy.search.query.SearchEventCache;
@ -469,7 +469,7 @@ public class yacysearchtrailer {
int ni = 0;
for (String naviname : theSearch.navigatorPlugins.keySet()) {
StringNavigator navi = theSearch.navigatorPlugins.get(naviname);
Navigator navi = theSearch.navigatorPlugins.get(naviname);
if (navi.isEmpty()) {
continue;
}

@ -93,4 +93,9 @@ public interface Navigator extends ScoreMap<String> {
* @return true if navigator key is mentioned as modifier
*/
public boolean modifieractive(QueryModifier modifier, String name);
/**
* @return the name of the index field, the fieldname counted in incDoc, incDoclList, incFacet
*/
public String getIndexFieldName();
}

@ -1,5 +1,5 @@
/**
* Navigator.java
* StringNavigator.java
* (C) 2016 by reger24; https://github.com/reger24
*
* This is a part of YaCy, a peer-to-peer based web search engine
@ -33,12 +33,13 @@ import net.yacy.search.query.QueryModifier;
import net.yacy.search.schema.CollectionSchema;
/**
*
* Search navigator for simple string entries based on ScoreMap to count and
* order the result list by counted occurence
*/
public class StringNavigator extends ConcurrentScoreMap<String> implements Navigator {
public String title;
public CollectionSchema field;
protected final CollectionSchema field;
public StringNavigator(String title, CollectionSchema field) {
super();
@ -138,4 +139,12 @@ public class StringNavigator extends ConcurrentScoreMap<String> implements Navi
return modifier.toString().contains(getQueryModifier() + "(" + name + ")");
}
}
@Override
public String getIndexFieldName() {
if (field != null)
return field.getSolrFieldName();
else
return "";
}
}

@ -156,7 +156,7 @@ public final class SearchEvent {
public final Map<String, ScoreMap<String>> vocabularyNavigator; // counters for Vocabularies; key is metatag.getVocabularyName()
private final int topicNavigatorCount; // if 0 no topicNavigator, holds expected number of terms for the topicNavigator
// map of search custom/configured search navigators in addition to above standard navigators (which use special handling or display forms)
public final Map<String, StringNavigator> navigatorPlugins; // map of active search navigators key=internal navigator name
public final Map<String, Navigator> navigatorPlugins; // map of active search navigators key=internal navigator name
private final LoaderDispatcher loader;
private final HandleSet snippetFetchWordHashes; // a set of word hashes that are used to match with the snippets
private final boolean deleteIfSnippetFail;
@ -270,7 +270,7 @@ public final class SearchEvent {
this.languageNavigator = navcfg.contains("language") ? new ConcurrentScoreMap<String>() : null;
this.vocabularyNavigator = new TreeMap<String, ScoreMap<String>>();
// prepare configured search navigation (plugins)
this.navigatorPlugins = new LinkedHashMap<String, StringNavigator>();
this.navigatorPlugins = new LinkedHashMap<String, Navigator>();
String[] navnames = navcfg.split(",");
for (String navname : navnames) {
if (navname.contains("authors")) {
@ -845,7 +845,7 @@ public final class SearchEvent {
for (String s : this.navigatorPlugins.keySet()) {
Navigator navi = this.navigatorPlugins.get(s);
if (navi != null) {
if (facets == null || facets.isEmpty()) { // just in case we got no solr facet
if (facets == null || facets.isEmpty() || !facets.containsKey(navi.getIndexFieldName())) { // just in case we got no solr facet
navi.incDocList(nodeList);
} else {
navi.incFacet(facets);

Loading…
Cancel
Save