bugfixes and more logging for solr connector

pull/1/head
Michael Peter Christen 12 years ago
parent bc00097cbf
commit 3834829b37

@ -48,9 +48,7 @@ public class schema {
c++; c++;
} }
} }
if (solrScheme.contains(YaCySchema.author)) { //if (solrScheme.contains(YaCySchema.author)) {addField(prop, c, YaCySchema.author_sxt);}
addField(prop, c, YaCySchema.author_sxt);
}
prop.put("fields", c); prop.put("fields", c);
prop.put("copyFieldAuthor", solrScheme.contains(YaCySchema.author) ? 1 : 0); prop.put("copyFieldAuthor", solrScheme.contains(YaCySchema.author) ? 1 : 0);

@ -96,6 +96,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
this.cores = new CoreContainer(storagePath.getAbsolutePath(), new File(solr_config, "solr.xml")); this.cores = new CoreContainer(storagePath.getAbsolutePath(), new File(solr_config, "solr.xml"));
} }
this.defaultCoreName = this.cores.getDefaultCoreName(); this.defaultCoreName = this.cores.getDefaultCoreName();
Log.logInfo("EmbeddedSolrConnector", "detected default solr core: " + this.defaultCoreName);
this.defaultCore = this.cores.getCore(this.defaultCoreName); // should be "collection1" this.defaultCore = this.cores.getCore(this.defaultCoreName); // should be "collection1"
if (this.defaultCore == null) { if (this.defaultCore == null) {
// try again // try again

@ -26,6 +26,7 @@ import java.net.InetAddress;
import net.yacy.cora.document.MultiProtocolURI; import net.yacy.cora.document.MultiProtocolURI;
import net.yacy.cora.protocol.Domains; import net.yacy.cora.protocol.Domains;
import net.yacy.kelondro.logging.Log;
import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpException;
import org.apache.http.Header; import org.apache.http.Header;
@ -48,12 +49,15 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpContext;
import org.apache.solr.client.solrj.ResponseParser; import org.apache.solr.client.solrj.ResponseParser;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.impl.XMLResponseParser; import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
public class RemoteSolrConnector extends SolrServerConnector implements SolrConnector { public class RemoteSolrConnector extends SolrServerConnector implements SolrConnector {
@ -130,8 +134,11 @@ public class RemoteSolrConnector extends SolrServerConnector implements SolrConn
BasicCredentialsProvider credsProvider = new BasicCredentialsProvider(); BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(this.host, AuthScope.ANY_PORT), new UsernamePasswordCredentials(this.solraccount, this.solrpw)); credsProvider.setCredentials(new AuthScope(this.host, AuthScope.ANY_PORT), new UsernamePasswordCredentials(this.solraccount, this.solrpw));
this.client.setCredentialsProvider(credsProvider); this.client.setCredentialsProvider(credsProvider);
s = new HttpSolrServer("http://" + this.host + ":" + this.port + this.solrpath, this.client); String p = "http://" + this.host + ":" + this.port + this.solrpath;
Log.logInfo("RemoteSolrConnector", "connecting Solr authenticated with url:" + p);
s = new HttpSolrServer(p, this.client);
} else { } else {
Log.logInfo("RemoteSolrConnector", "connecting Solr with url:" + this.solrurl);
s = new HttpSolrServer(this.solrurl); s = new HttpSolrServer(this.solrurl);
} }
s.setAllowCompression(true); s.setAllowCompression(true);

@ -30,6 +30,7 @@ import net.yacy.cora.document.UTF8;
import net.yacy.cora.federate.solr.YaCySchema; import net.yacy.cora.federate.solr.YaCySchema;
import net.yacy.cora.sorting.ClusteredScoreMap; import net.yacy.cora.sorting.ClusteredScoreMap;
import net.yacy.cora.sorting.ReversibleScoreMap; import net.yacy.cora.sorting.ReversibleScoreMap;
import net.yacy.kelondro.logging.Log;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrQuery;
@ -103,8 +104,8 @@ public abstract class SolrServerConnector extends AbstractSolrConnector implemen
public synchronized void commit(final boolean softCommit) { public synchronized void commit(final boolean softCommit) {
try { try {
this.server.commit(true, true, softCommit); this.server.commit(true, true, softCommit);
} catch (SolrServerException e) { } catch (Throwable e) {
} catch (IOException e) { Log.logException(e);
} }
} }
@ -115,8 +116,8 @@ public abstract class SolrServerConnector extends AbstractSolrConnector implemen
public void optimize(int maxSegments) { public void optimize(int maxSegments) {
try { try {
this.server.optimize(true, true, maxSegments); this.server.optimize(true, true, maxSegments);
} catch (SolrServerException e) { } catch (Throwable e) {
} catch (IOException e) { Log.logException(e);
} }
} }
@ -125,10 +126,8 @@ public abstract class SolrServerConnector extends AbstractSolrConnector implemen
try { try {
if (this.server != null) synchronized (this.server) {this.server.commit(true, true, false);} if (this.server != null) synchronized (this.server) {this.server.commit(true, true, false);}
this.server = null; this.server = null;
} catch (SolrServerException e) { } catch (Throwable e) {
log.warn(e); Log.logException(e);
} catch (IOException e) {
log.warn(e);
} }
} }

@ -67,6 +67,7 @@ import net.yacy.kelondro.util.Bitfield;
import net.yacy.kelondro.util.SetTools; import net.yacy.kelondro.util.SetTools;
import net.yacy.peers.Seed; import net.yacy.peers.Seed;
import net.yacy.search.index.Segment; import net.yacy.search.index.Segment;
import net.yacy.search.index.SolrConfiguration;
import net.yacy.search.ranking.RankingProfile; import net.yacy.search.ranking.RankingProfile;
public final class QueryParams { public final class QueryParams {
@ -83,11 +84,8 @@ public final class QueryParams {
} }
} }
private static final String[] defaultfacetfields = new String[]{ private static final YaCySchema[] defaultfacetfields = new YaCySchema[]{
YaCySchema.host_s.getSolrFieldName(), YaCySchema.host_s, YaCySchema.url_protocol_s, YaCySchema.url_file_ext_s, YaCySchema.author_sxt};
YaCySchema.url_protocol_s.getSolrFieldName(),
YaCySchema.url_file_ext_s.getSolrFieldName(),
YaCySchema.author_sxt.getSolrFieldName()};
private static final int defaultmaxfacets = 30; private static final int defaultmaxfacets = 30;
@ -146,6 +144,7 @@ public final class QueryParams {
public List<String> facetfields; public List<String> facetfields;
public int maxfacets; public int maxfacets;
private SolrQuery cachedQuery; private SolrQuery cachedQuery;
private SolrConfiguration solrScheme;
// the following values are filled during the search process as statistics for the search // the following values are filled during the search process as statistics for the search
public final AtomicInteger local_rwi_available; // the number of hits generated/ranked by the local search in rwi index public final AtomicInteger local_rwi_available; // the number of hits generated/ranked by the local search in rwi index
@ -158,7 +157,8 @@ public final class QueryParams {
public final SortedSet<byte[]> misses; // url hashes that had been sorted out because of constraints in postranking public final SortedSet<byte[]> misses; // url hashes that had been sorted out because of constraints in postranking
public QueryParams( public QueryParams(
final String query_original, final String query_words, final String query_original,
final String query_words,
final int itemsPerPage, final int itemsPerPage,
final Bitfield constraint, final Bitfield constraint,
final Segment indexSegment, final Segment indexSegment,
@ -210,7 +210,12 @@ public final class QueryParams {
this.remote_available = new AtomicInteger(0); // the number of result contributions from all the remote peers this.remote_available = new AtomicInteger(0); // the number of result contributions from all the remote peers
this.remote_peerCount = new AtomicInteger(0); // the number of remote peers that have contributed this.remote_peerCount = new AtomicInteger(0); // the number of remote peers that have contributed
this.misses = Collections.synchronizedSortedSet(new TreeSet<byte[]>(URIMetadataRow.rowdef.objectOrder)); this.misses = Collections.synchronizedSortedSet(new TreeSet<byte[]>(URIMetadataRow.rowdef.objectOrder));
this.facetfields = new ArrayList<String>(); for (String f: defaultfacetfields) facetfields.add(f); this.facetfields = new ArrayList<String>();
this.solrScheme = indexSegment.fulltext().getSolrScheme();
for (YaCySchema f: defaultfacetfields) {
if (solrScheme.contains(f)) facetfields.add(f.getSolrFieldName());
}
for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX); for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX);
this.maxfacets = defaultmaxfacets; this.maxfacets = defaultmaxfacets;
this.cachedQuery = null; this.cachedQuery = null;
@ -312,7 +317,12 @@ public final class QueryParams {
this.remote_available = new AtomicInteger(0); // the number of result contributions from all the remote peers this.remote_available = new AtomicInteger(0); // the number of result contributions from all the remote peers
this.remote_peerCount = new AtomicInteger(0); // the number of remote peers that have contributed this.remote_peerCount = new AtomicInteger(0); // the number of remote peers that have contributed
this.misses = Collections.synchronizedSortedSet(new TreeSet<byte[]>(URIMetadataRow.rowdef.objectOrder)); this.misses = Collections.synchronizedSortedSet(new TreeSet<byte[]>(URIMetadataRow.rowdef.objectOrder));
this.facetfields = new ArrayList<String>(); for (String f: defaultfacetfields) facetfields.add(f); this.facetfields = new ArrayList<String>();
this.solrScheme = indexSegment.fulltext().getSolrScheme();
for (YaCySchema f: defaultfacetfields) {
if (solrScheme.contains(f)) facetfields.add(f.getSolrFieldName());
}
for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX); for (Tagging v: LibraryProvider.autotagging.getVocabularies()) this.facetfields.add(YaCySchema.VOCABULARY_PREFIX + v.getName() + YaCySchema.VOCABULARY_SUFFIX);
this.maxfacets = defaultmaxfacets; this.maxfacets = defaultmaxfacets;
this.cachedQuery = null; this.cachedQuery = null;
@ -477,7 +487,7 @@ public final class QueryParams {
} }
// add author facets // add author facets
if (this.author != null && this.author.length() > 0) { if (this.author != null && this.author.length() > 0 && this.solrScheme.contains(YaCySchema.author_sxt)) {
fq.append(" AND ").append(YaCySchema.author_sxt.getSolrFieldName()).append(":\"").append(this.author).append('\"'); fq.append(" AND ").append(YaCySchema.author_sxt.getSolrFieldName()).append(":\"").append(this.author).append('\"');
} }

Loading…
Cancel
Save