Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added an artificial snippet [Synonym Match] in case that there is only a match in the synonyms]
Michael Peter Christena8c64b1af2c7
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.javaindex 28e3d14b7..d543bfd4e 100644--- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java+++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java@@ -516,6 +516,10 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMepublic WordReferenceVars word() {return this.word;}++ public ArrayList<String> getSynonyms() {+ return getStringList(CollectionSchema.synonyms_sxt);+ }public static Iterator<String> getLinks(SolrDocument doc, boolean inbound) {Collection<Object> urlstub = doc.getFieldValues((inbound ? CollectionSchema.inboundlinks_urlstub_sxt : CollectionSchema.outboundlinks_urlstub_sxt).getSolrFieldName());diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.javaindex afb1ee60d..ea3774897 100644--- a/source/net/yacy/search/query/SearchEvent.java+++ b/source/net/yacy/search/query/SearchEvent.java@@ -2056,6 +2056,21 @@ public final class SearchEvent implements ScoreMapUpdatesListener {if (this.deleteIfSnippetFail) {this.workTables.failURLsRegisterMissingWord(this.query.getSegment().termIndex(), page.url(), this.query.getQueryGoal().getIncludeHashes());}+ // to make an exception in case matches are only in the synonym field, we load the synonym field to check if the word is there+ final ArrayList<String> synonyms = page.getSynonyms();+ if (synonyms != null) {+ Iterator<String> words = this.query.getQueryGoal().getIncludeWords();+ while (words.hasNext()) {+ String word = words.next().toLowerCase();+ for (final String synonym : synonyms) {+ if (synonym.toLowerCase().equals(word)) {+ SearchEvent.log.info("accepted url " + page.url().toNormalform(true) + " without snippet: hit in synonyms field");+ TextSnippet synonym_snippet = new TextSnippet(page.url(), "[Synonym Match]", true, ResultClass.SOURCE_METADATA, "");+ return page.makeResultEntry(this.query.getSegment(), this.peers, synonym_snippet);+ }+ }+ }+ }SearchEvent.log.info("sorted out url " + page.url().toNormalform(true) + " during search: " + reason);return null;}