EventTracker.delete(EventTracker.EClass.SEARCH);
final HandleSet abstractSet = (abstracts.length() == 0 || abstracts.equals("auto")) ? null : QueryParams.hashes2Set(abstracts);
// store accessing peer
yacySeed remoteSeed;
try {
remoteSeed = yacySeed.genRemoteSeed(oseed, key, false, client);
} catch (final IOException e) {
yacyCore.log.logInfo("yacy.search: access with bad seed: " + e.getMessage());
remoteSeed = null;
}
if (sb.peers == null) {
yacyCore.log.logSevere("yacy.search: seed cache not initialized");
} else {
sb.peers.peerActions.peerArrival(remoteSeed, true);
}
// prepare search
final HandleSet queryhashes = QueryParams.hashes2Set(query);
final HandleSet excludehashes = (exclude.length() == 0) ? new HandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0) : QueryParams.hashes2Set(exclude);
final long timestamp = System.currentTimeMillis();
// prepare a search profile
final RankingProfile rankingProfile = (profile.length() == 0) ? new RankingProfile(ContentDomain.contentdomParser(contentdom)) : new RankingProfile("", profile);
// prepare an abstract result
final StringBuilder indexabstract = new StringBuilder(6000);
int indexabstractContainercount = 0;
int joincount = 0;
QueryParams theQuery = null;
SearchEvent theSearch = null;
ArrayList<WeakPriorityBlockingQueue.Element<ResultEntry>> accu = null;
if (query.length() == 0 && abstractSet != null) {
// this is _not_ a normal search, only a request for index abstracts
final Segment indexSegment = sb.indexSegments.segment(Segments.Process.PUBLIC);
theQuery = new QueryParams(
null,
abstractSet,
new HandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0),
null,
snippetPattern,
null,
maxdist,
prefer,
ContentDomain.contentdomParser(contentdom),
language,
"", // no navigation
CacheStrategy.CACHEONLY,
count,
0,
filter,
QueryParams.SEARCHDOM_LOCAL,
-1,
null,
false,
sitehash,
authorhash,
DigestURI.TLD_any_zone_filter,
client,
false,
indexSegment,
rankingProfile,
header.get(RequestHeader.USER_AGENT, ""),
false
);
yacyCore.log.logInfo("INIT HASH SEARCH (abstracts only): " + QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.displayResults() + " links");
final long timer = System.currentTimeMillis();
//final Map<byte[], ReferenceContainer<WordReference>>[] containers = sb.indexSegment.index().searchTerm(theQuery.queryHashes, theQuery.excludeHashes, plasmaSearchQuery.hashes2StringSet(urls));
final TreeMap<byte[], ReferenceContainer<WordReference>> incc = indexSegment.termIndex().searchConjunction(theQuery.queryHashes, QueryParams.hashes2Handles(urls));
EventTracker.update(EventTracker.EClass.SEARCH, new ProfilingGraph.searchEvent(theQuery.id(true), SearchEvent.Type.COLLECTION, "", incc.size(), System.currentTimeMillis() - timer), false);
if (incc != null) {
final Iterator<Map.Entry<byte[], ReferenceContainer<WordReference>>> ci = incc.entrySet().iterator();
Map.Entry<byte[], ReferenceContainer<WordReference>> entry;
byte[] wordhash;
while (ci.hasNext()) {
entry = ci.next();
wordhash = entry.getKey();
final ReferenceContainer<WordReference> container = entry.getValue();
indexabstractContainercount += container.size();
indexabstract.append("indexabstract.");
indexabstract.append(ASCII.String(wordhash));
indexabstract.append("=");
indexabstract.append(WordReferenceFactory.compressIndex(container, null, 1000).toString());
indexabstract.append(serverCore.CRLF_STRING);
}
}
prop.put("indexcount", "");
prop.put("joincount", "0");
prop.put("references", "");
} else {
// retrieve index containers from search request
theQuery = new QueryParams(
null,
queryhashes,
excludehashes,
null,
snippetPattern,
null,
maxdist,
prefer,
ContentDomain.contentdomParser(contentdom),
language,
"", // no navigation
CacheStrategy.CACHEONLY,
count,
0,
filter,
QueryParams.SEARCHDOM_LOCAL,
-1,
constraint,
false,
sitehash,
authorhash,
DigestURI.TLD_any_zone_filter,
client,
false,
sb.indexSegments.segment(Segments.Process.PUBLIC),
rankingProfile,
header.get(RequestHeader.USER_AGENT, ""),
false
);
yacyCore.log.logInfo("INIT HASH SEARCH (query-" + abstracts + "): " + QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.displayResults() + " links");
yacyChannel.channels(yacyChannel.REMOTESEARCH).addMessage(new RSSMessage("Remote Search Request from " + ((remoteSeed == null) ? "unknown" : remoteSeed.getName()), QueryParams.anonymizedQueryHashes(theQuery.queryHashes), ""));
// make event
theSearch = SearchEventCache.getEvent(theQuery, sb.peers, sb.tables, null, abstracts.length() > 0, sb.loader, count, maxtime, (int) sb.getConfigLong(SwitchboardConstants.DHT_BURST_ROBINSON, 0), (int) sb.getConfigLong(SwitchboardConstants.DHT_BURST_MULTIWORD, 0));
// set statistic details of search result and find best result index set