Skip to content

Commit

Permalink
addendum to last commit
Browse files Browse the repository at this point in the history
handle words with length < 3 correctly

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5369 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
lotus committed Nov 26, 2008
1 parent 325ba7b commit 1951d30
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions htroot/yacy/search.java
Expand Up @@ -180,7 +180,7 @@ public static serverObjects respond(final httpRequestHeader header, final server
plasmaSearchEvent theSearch = null;
if ((query.length() == 0) && (abstractSet != null)) {
// this is _not_ a normal search, only a request for index abstracts
theQuery = new plasmaSearchQuery(null, abstractSet, new TreeSet<String>(kelondroBase64Order.enhancedComparator), rankingProfile, maxdist, prefer, plasmaSearchQuery.contentdomParser(contentdom), language, false, count, 0, filter, plasmaSearchQuery.SEARCHDOM_LOCAL, null, -1, null, false, yacyURL.TLD_any_zone_filter, client, false);
theQuery = new plasmaSearchQuery(null, abstractSet, new TreeSet<String>(kelondroBase64Order.enhancedComparator), null, rankingProfile, maxdist, prefer, plasmaSearchQuery.contentdomParser(contentdom), language, false, count, 0, filter, plasmaSearchQuery.SEARCHDOM_LOCAL, null, -1, null, false, yacyURL.TLD_any_zone_filter, client, false);
theQuery.domType = plasmaSearchQuery.SEARCHDOM_LOCAL;
yacyCore.log.logInfo("INIT HASH SEARCH (abstracts only): " + plasmaSearchQuery.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.displayResults() + " links");

Expand All @@ -206,7 +206,7 @@ public static serverObjects respond(final httpRequestHeader header, final server

} else {
// retrieve index containers from search request
theQuery = new plasmaSearchQuery(null, queryhashes, excludehashes, rankingProfile, maxdist, prefer, plasmaSearchQuery.contentdomParser(contentdom), language, false, count, 0, filter, plasmaSearchQuery.SEARCHDOM_LOCAL, null, -1, constraint, false, yacyURL.TLD_any_zone_filter, client, false);
theQuery = new plasmaSearchQuery(null, queryhashes, excludehashes, null, rankingProfile, maxdist, prefer, plasmaSearchQuery.contentdomParser(contentdom), language, false, count, 0, filter, plasmaSearchQuery.SEARCHDOM_LOCAL, null, -1, constraint, false, yacyURL.TLD_any_zone_filter, client, false);
theQuery.domType = plasmaSearchQuery.SEARCHDOM_LOCAL;
yacyCore.log.logInfo("INIT HASH SEARCH (query-" + abstracts + "): " + plasmaSearchQuery.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.displayResults() + " links");
RSSFeed.channels(RSSFeed.REMOTESEARCH).addMessage(new RSSMessage("Remote Search Request from " + ((remoteSeed == null) ? "unknown" : remoteSeed.getName()), plasmaSearchQuery.anonymizedQueryHashes(theQuery.queryHashes), ""));
Expand Down
3 changes: 2 additions & 1 deletion htroot/yacy/user/ysearch.java
Expand Up @@ -207,7 +207,8 @@ public static serverObjects respond(final httpRequestHeader header, final server
querystring,
queryHashes,
indexWord.words2hashes(query[1]),
ranking,
indexWord.words2hashes(query[2]),
ranking,
maxDistance,
prefermask,
contentdomCode,
Expand Down
2 changes: 1 addition & 1 deletion htroot/yacy/user/ysearchitem.java
Expand Up @@ -134,7 +134,7 @@ public static serverObjects respond(final httpRequestHeader header, final server
((yacyURL.probablyRootURL(result.hash())) ? ", probablyRootURL" : "") +
(((wordURL = yacyURL.probablyWordURL(result.hash(), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : ""));
final plasmaSnippetCache.TextSnippet snippet = result.textSnippet();
prop.put("content_snippet", (snippet == null) ? "(snippet not found)" : snippet.getLineMarked(theQuery.queryHashes));
prop.put("content_snippet", (snippet == null) ? "(snippet not found)" : snippet.getLineMarked(theQuery.fullqueryHashes));
return prop;
}

Expand Down
3 changes: 2 additions & 1 deletion htroot/yacysearch.java
Expand Up @@ -282,7 +282,8 @@ public static serverObjects respond(final httpRequestHeader header, final server
querystring,
queryHashes,
indexWord.words2hashes(query[1]),
ranking,
indexWord.words2hashes(query[2]),
ranking,
maxDistance,
prefermask,
contentdomCode,
Expand Down
14 changes: 9 additions & 5 deletions source/de/anomic/plasma/plasmaSearchQuery.java
Expand Up @@ -117,6 +117,7 @@ public plasmaSearchQuery(final String queryString,
public plasmaSearchQuery(
final String queryString, final TreeSet<String> queryHashes,
final TreeSet<String> excludeHashes,
final TreeSet<String> fullqueryHashes,
final plasmaSearchRankingProfile ranking,
final int maxDistance, final String prefer, final int contentdom,
final String language,
Expand All @@ -130,7 +131,7 @@ public plasmaSearchQuery(
this.queryString = queryString;
this.queryHashes = queryHashes;
this.excludeHashes = excludeHashes;
this.fullqueryHashes = queryHashes; //FIXME: refactor this method to get the proper hashes
this.fullqueryHashes = fullqueryHashes;
this.ranking = ranking;
this.maxDistance = maxDistance;
this.prefer = prefer;
Expand Down Expand Up @@ -248,6 +249,7 @@ public static TreeSet<String>[] cleanQuery(String querystring) {
}

String s;
int l;
// the string is clean now, but we must generate a set out of it
final TreeSet<String> query = new TreeSet<String>(kelondroNaturalOrder.naturalComparator);
final TreeSet<String> exclude = new TreeSet<String>(kelondroNaturalOrder.naturalComparator);
Expand All @@ -259,12 +261,14 @@ public static TreeSet<String>[] cleanQuery(String querystring) {
} else {
while ((c = a[i].indexOf('-')) >= 0) {
s = a[i].substring(0, c);
if(s.length() > 2) query.add(s);
fullquery.add(s);
l = s.length();
if(l > 2) query.add(s);
if(l > 0) fullquery.add(s);
a[i] = a[i].substring(c + 1);
}
if (a[i].length() > 2) query.add(a[i]);
fullquery.add(a[i]);
l = a[i].length();
if (l > 2) query.add(a[i]);
if (l > 0) fullquery.add(a[i]);
}
}
return new TreeSet[]{query, exclude, fullquery};
Expand Down

0 comments on commit 1951d30

Please sign in to comment.