increaesed ability ot search for all images on a single server within

the p2p remote search
pull/1/head
Michael Peter Christen 11 years ago
parent 2c26013c50
commit 81f9b34da7

@ -262,7 +262,7 @@ public class yacysearch {
}
// find search domain
final Classification.ContentDomain contentdom = ContentDomain.contentdomParser(post == null ? "all" : post.get("contentdom", "all"));
final Classification.ContentDomain contentdom = post == null || !post.containsKey("contentdom") ? ContentDomain.ALL : ContentDomain.contentdomParser(post.get("contentdom", "all"));
// patch until better search profiles are available
if (contentdom == ContentDomain.IMAGE && (itemsPerPage == 10 || itemsPerPage == 100)) {

@ -85,7 +85,7 @@ public class DHTSelection {
final SeedDB seedDB,
final HandleSet wordhashes,
final int minage,
final Set<Seed> omit,
final Collection<Seed> omit,
final int maxcount,
final Random r) {

@ -39,10 +39,12 @@ import net.yacy.cora.document.encoding.ASCII;
import net.yacy.cora.storage.HandleSet;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.cora.util.Memory;
import net.yacy.kelondro.data.word.Word;
import net.yacy.kelondro.util.MemoryControl;
import net.yacy.repository.Blacklist;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.index.Segment;
import net.yacy.search.query.QueryParams;
import net.yacy.search.query.SearchEvent;
import net.yacy.search.query.SecondarySearchSuperviser;
@ -166,10 +168,28 @@ public class RemoteSearch extends Thread {
// prepare seed targets and threads
Random random = new Random(System.currentTimeMillis());
Set<Seed> dhtPeers = null;
Collection<Seed> dhtPeers = null;
if (clusterselection != null) {
dhtPeers = DHTSelection.selectClusterPeers(event.peers, clusterselection);
} else {
if (event.query.getQueryGoal().isCatchall() || event.query.getQueryGoal().getIncludeHashes().has(Segment.catchallHash)) {
if (event.query.modifier.sitehost != null && event.query.modifier.sitehost.length() > 0) {
// select peers according to host name, not the query goal
String[] hp = event.query.modifier.sitehost.split("\\.");
String newGoal = hp.length <= 1 ? event.query.modifier.sitehost : hp.length == 2 ? hp[0] : hp[hp.length - 2].length() == 2 ? hp[hp.length - 3] : hp[hp.length - 2];
dhtPeers = DHTSelection.selectDHTSearchTargets(
event.peers,
QueryParams.hashes2Set(ASCII.String(Word.word2hash(newGoal))),
minage,
redundancy, event.peers.redundancy(),
random);
} else {
// select just random peers
dhtPeers = DHTSelection.seedsByAge(event.peers, false, count).values();
}
}
dhtPeers = DHTSelection.selectDHTSearchTargets(
event.peers,
event.query.getQueryGoal().getIncludeHashes(),

@ -663,11 +663,7 @@ public class Segment {
// assign the catchall word
ientry.setWord(wprop == null ? catchallWord : wprop); // we use one of the word properties as template to get the document characteristics
if (this.termIndex != null) try {
this.termIndex.add(catchallHash, ientry);
} catch (final Exception e) {
ConcurrentLog.logException(e);
}
if (this.termIndex != null) try {this.termIndex.add(catchallHash, ientry);} catch (final Throwable e) {ConcurrentLog.logException(e);}
}
// finish index time

@ -287,9 +287,9 @@ public class QueryGoal {
}
public boolean isCatchall() {
if (include_strings.size() != 1 || exclude_strings.size() != 0) return false;
String w = include_strings.get(0);
return (Segment.catchallString.equals(w));
if (this.include_hashes != null && this.include_hashes.has(Segment.catchallHash)) return true;
if (this.include_strings == null || this.include_strings.size() != 1) return false;
return (this.include_strings.contains(Segment.catchallString));
}
public boolean containsInclude(String word) {
@ -332,30 +332,30 @@ public class QueryGoal {
// parse special requests
if (isCatchall()) return q;
q.append(" AND (");
// add goal query
int wc = 0;
StringBuilder w = getGoalQuery();
// combine these queries for all relevant fields
wc = 0;
Float boost;
Ranking r = configuration.getRanking(rankingProfile);
for (Map.Entry<SchemaDeclaration,Float> entry: r.getBoostMap()) {
SchemaDeclaration field = entry.getKey();
boost = entry.getValue();
if (boost == null || boost.floatValue() <= 0.0f) continue;
if (configuration != null && !configuration.contains(field.getSolrFieldName())) continue;
if (field.getType() == SolrType.num_integer) continue;
if (wc > 0) q.append(" OR ");
q.append('(');
q.append(field.getSolrFieldName()).append(':').append(w);
if (boost != null) q.append('^').append(boost.toString());
if (w.length() > 0) {
q.append(" AND (");
int wc = 0;
Float boost;
Ranking r = configuration.getRanking(rankingProfile);
for (Map.Entry<SchemaDeclaration,Float> entry: r.getBoostMap()) {
SchemaDeclaration field = entry.getKey();
boost = entry.getValue();
if (boost == null || boost.floatValue() <= 0.0f) continue;
if (configuration != null && !configuration.contains(field.getSolrFieldName())) continue;
if (field.getType() == SolrType.num_integer) continue;
if (wc > 0) q.append(" OR ");
q.append('(');
q.append(field.getSolrFieldName()).append(':').append(w);
if (boost != null) q.append('^').append(boost.toString());
q.append(')');
wc++;
}
q.append(')');
wc++;
}
q.append(')');
return q;
}
@ -376,13 +376,15 @@ public class QueryGoal {
StringBuilder w = getGoalQuery();
// combine these queries for all relevant fields
q.append(" AND (");
q.append('(').append(CollectionSchema.images_text_t.getSolrFieldName()).append(':').append(w).append("^100.0) OR ");
q.append('(').append(CollectionSchema.title.getSolrFieldName()).append(':').append(w).append("^50.0) OR ");
q.append('(').append(CollectionSchema.keywords.getSolrFieldName()).append(':').append(w).append("^10.0) OR ");
q.append('(').append(CollectionSchema.text_t.getSolrFieldName()).append(':').append(w).append(')');
q.append(')');
if (w.length() > 0) {
q.append(" AND (");
q.append('(').append(CollectionSchema.images_text_t.getSolrFieldName()).append(':').append(w).append("^100.0) OR ");
q.append('(').append(CollectionSchema.title.getSolrFieldName()).append(':').append(w).append("^50.0) OR ");
q.append('(').append(CollectionSchema.keywords.getSolrFieldName()).append(':').append(w).append("^10.0) OR ");
q.append('(').append(CollectionSchema.text_t.getSolrFieldName()).append(':').append(w).append(')');
q.append(')');
}
return q;
}
@ -390,6 +392,7 @@ public class QueryGoal {
int wc = 0;
StringBuilder w = new StringBuilder(80);
for (String s: include_strings) {
if (Segment.catchallString.equals(s)) continue;
if (wc > 0) w.append(" AND ");
w.append(dq).append(s).append(dq);
wc++;

Loading…
Cancel
Save