diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java index 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 String[] collections() { public WordReferenceVars word() { return this.word; } + + public ArrayList getSynonyms() { + return getStringList(CollectionSchema.synonyms_sxt); + } public static Iterator getLinks(SolrDocument doc, boolean inbound) { Collection 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.java index afb1ee60d..ea3774897 100644 --- a/source/net/yacy/search/query/SearchEvent.java +++ b/source/net/yacy/search/query/SearchEvent.java @@ -2056,6 +2056,21 @@ public URIMetadataNode getSnippet(URIMetadataNode page, final CacheStrategy cach 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 synonyms = page.getSynonyms(); + if (synonyms != null) { + Iterator 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; }