Skip to content

Commit

Permalink
testing to use solr for portalsearch caused some bugfixing but no full
Browse files Browse the repository at this point in the history
success: try to comment out the solr search request in
yacy-portalsearch.js
  • Loading branch information
Orbiter committed Feb 25, 2013
1 parent 0082887 commit 35fa718
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
5 changes: 3 additions & 2 deletions htroot/portalsearch/yacy-portalsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ function yrun() {

function yacysearch(clear) {
var url = yconf.url + '/yacysearch.json?callback=?' // JSONP (cross domain) request URL
//var url = yconf.url + '/solr/select?wt=yjson&jsonp=?' // JSONP (cross domain) request URL

if(clear) {
$('#ypopup').empty();
Expand Down Expand Up @@ -244,7 +245,7 @@ function yacysearch(clear) {

$.ajaxSetup({
timeout: 10000,
error: function(x,e) {
error: function(x,e,ex) {
var err = 'Unknow Error: '+x.responseText;
if(x.status==0) {
err = 'Unknown Network Error! I try to reload...';
Expand All @@ -254,7 +255,7 @@ function yacysearch(clear) {
} else if(x.status==500) {
err = x.status + ' - Internel Server Error.';
} else if(e=='parsererror') {
err = 'Parsing JSON Request failed.';
err = 'Parsing JSON Request failed:' + ex;
} else if(e=='timeout') {
err = 'Request Time out.';
};
Expand Down
17 changes: 11 additions & 6 deletions htroot/solr/select.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.query.AccessTracker;
import net.yacy.search.query.QueryGoal;
import net.yacy.search.query.QueryModifier;
import net.yacy.search.query.SearchEvent;
import net.yacy.search.schema.CollectionSchema;
Expand Down Expand Up @@ -142,7 +143,6 @@ public static serverObjects respond(final RequestHeader header, final serverObje

// check post
if (post == null) return null;
Log.logInfo("SOLR Query", post.toString());
sb.intermissionAllThreads(3000); // tell all threads to do nothing for a specific time

// rename post fields according to result style
Expand All @@ -152,12 +152,14 @@ public static serverObjects respond(final RequestHeader header, final serverObje
QueryModifier modifier = new QueryModifier();
querystring = modifier.parse(querystring);
modifier.apply(post);
post.put(CommonParams.Q, querystring); // sru patch
QueryGoal qg = new QueryGoal(querystring, querystring);
StringBuilder solrQ = qg.solrQueryString(sb.index.fulltext().getDefaultConfiguration());
post.put(CommonParams.Q, solrQ.toString()); // sru patch
}
String q = post.get(CommonParams.Q, "");
if (!post.containsKey(CommonParams.START)) post.put(CommonParams.START, post.remove("startRecord")); // sru patch
post.put(CommonParams.ROWS, Math.min(post.getInt(CommonParams.ROWS, post.getInt("maximumRecords", 10)), (authenticated) ? 5000 : 100));
post.remove("maximumRecords");
if (!post.containsKey(CommonParams.START)) post.put(CommonParams.START, post.remove("startRecord", 0)); // sru patch
if (!post.containsKey(CommonParams.ROWS)) post.put(CommonParams.ROWS, post.remove("maximumRecords", 10)); // sru patch
post.put(CommonParams.ROWS, Math.min(post.getInt(CommonParams.ROWS, 10), (authenticated) ? 10000 : 100));

// get a response writer for the result
String wt = post.get(CommonParams.WT, "xml"); // maybe use /solr/select?q=*:*&start=0&rows=10&wt=exml
Expand Down Expand Up @@ -212,9 +214,12 @@ public static serverObjects respond(final RequestHeader header, final serverObje

// log result
Object rv = response.getValues().get("response");
int matches = ((ResultContext) rv).docs.matches();
if (rv != null && rv instanceof ResultContext) {
AccessTracker.addToDump(q, Integer.toString(((ResultContext) rv).docs.matches()));
AccessTracker.addToDump(q, Integer.toString(matches));
}

Log.logInfo("SOLR Query", "results: " + matches + ", for query:" + post.toString());
return null;
}
}
2 changes: 1 addition & 1 deletion source/net/yacy/kelondro/logging/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ protected final static class logEntry {
private Throwable thrown;
private logEntry(final Level level, final String message) {
this.level = level;
this.message = message == null || message.length() <= 512 ? message : message.substring(0, 512);
this.message = message == null || message.length() <= 1024 ? message : message.substring(0, 1024);
}
public logEntry(final Logger logger, final Level level, final String message, final Throwable thrown) {
this(level, message);
Expand Down
2 changes: 2 additions & 0 deletions source/net/yacy/search/query/QueryGoal.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.SortedSet;

import net.yacy.cora.federate.solr.Boost;
import net.yacy.cora.federate.solr.SolrType;
import net.yacy.cora.storage.HandleSet;
import net.yacy.document.parser.html.AbstractScraper;
import net.yacy.document.parser.html.CharacterCoding;
Expand Down Expand Up @@ -234,6 +235,7 @@ public StringBuilder solrQueryString(CollectionConfiguration configuration) {
CollectionSchema field = entry.getKey();
if (entry.getValue().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);
Expand Down
15 changes: 13 additions & 2 deletions source/net/yacy/server/serverObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,22 @@ public Set<String> values() {
public Set<String> keySet() {
return this.map.getMap().keySet();
}

public String[] remove(String key) {
return this.map.getMap().remove(key);
}

public int remove(String key, int dflt) {
final String result = removeByteOrderMark(get(key));
this.map.getMap().remove(key);
if (result == null) return dflt;
try {
return Integer.parseInt(result);
} catch (NumberFormatException e) {
return dflt;
}
}

public void putAll(Map<String, String> m) {
for (Map.Entry<String, String> e: m.entrySet()) {
put(e.getKey(), e.getValue());
Expand Down Expand Up @@ -372,7 +383,7 @@ public String[] getParams(String name) {

public String get(String name) {
String[] arr = map.getMap().get(name);
return arr==null ? null : arr[0];
return arr == null || arr.length == 0 ? null : arr[0];
}

// new get with default objects
Expand Down
3 changes: 0 additions & 3 deletions source/net/yacy/upnp/impls/InternetGatewayDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@
import net.yacy.upnp.messages.UPNPResponseException;
import net.yacy.upnp.services.UPNPService;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* This class can be used to access some funtionalities on the
* InternetGatewayDevice on your network without having to know
Expand Down

0 comments on commit 35fa718

Please sign in to comment.