fixed a problem with Date fields parsing Solr results if a remote Solr

is attached.
pull/1/head
Michael Peter Christen 11 years ago
parent 94db054aff
commit 9932c441c8

@ -81,13 +81,6 @@ public abstract class AbstractSolrConnector implements SolrConnector {
}
}
@Override
public String getFieldById(final String key, final String field) throws IOException {
SolrDocument doc = getDocumentById(key, field);
if (doc == null) return null;
return doc.getFieldValue(field).toString();
}
/**
* Get a query result from solr as a stream of documents.
* The result queue is considered as terminated if AbstractSolrConnector.POISON_DOCUMENT is returned.

@ -409,16 +409,6 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector {
}
}
@Override
public String getFieldById(String id, String field) throws IOException {
if (existIdFromDeleteQueue(id)) return null;
SolrInputDocument doc = getFromUpdateQueue(id);
if (doc != null) {cacheSuccessSign(); return doc.getFieldValue(field).toString();}
String val = this.connector.getFieldById(id, field);
if (val != null) updateIdCache(id);
return val;
}
@Override
public SolrDocument getDocumentById(String id, String... fields) throws IOException {
if (existIdFromDeleteQueue(id)) return null;

@ -280,27 +280,6 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
return idsr;
}
@Override
public String getFieldById(final String id, final String field) throws IOException {
String ret = null;
DocListSearcher docListSearcher = null;
try {
docListSearcher = new DocListSearcher("{!raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id, 0, 1, CollectionSchema.id.getSolrFieldName());
int numFound = docListSearcher.response.matches();
if (numFound > 0) {
Set<String> solrFields = new HashSet<String>();
solrFields.add(field);
Document doc = docListSearcher.request.getSearcher().doc(docListSearcher.response.iterator().nextDoc(), solrFields);
ret = doc.get(field);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (docListSearcher != null) docListSearcher.close();
}
return ret;
}
@Override
public BlockingQueue<String> concurrentIDsByQuery(final String querystring, final int offset, final int maxcount, final long maxtime) {
final BlockingQueue<String> queue = new LinkedBlockingQueue<String>();

@ -364,15 +364,6 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
return s;
}
@Override
public String getFieldById(String key, String field) throws IOException {
if (this.solr0 != null && this.solr1 == null) return this.solr0.getFieldById(key, field);
if (this.solr0 == null && this.solr1 != null) return this.solr1.getFieldById(key, field);
String value = this.solr0.getFieldById(key, field);
if (value != null) return value;
return this.solr1.getFieldById(key, field);
}
/*
@Override
public BlockingQueue<SolrDocument> concurrentDocumentsByQuery(String querystring, int offset, int maxcount, long maxtime, int buffersize, String... fields) {

@ -137,15 +137,6 @@ public interface SolrConnector extends Iterable<String> /* Iterable of document
*/
public void add(final Collection<SolrInputDocument> solrdoc) throws IOException, SolrException;
/**
* get a field value from solr by given key for the id-field and a field name
* @param key
* @param field one field
* @return one result or null if no result exists
* @throws IOException
*/
public String getFieldById(final String key, final String field) throws IOException;
/**
* get a document from solr by given key for the id-field
* @param key

@ -308,31 +308,30 @@ public final class Fulltext {
public Date getLoadDate(final String urlHash) {
if (urlHash == null) return null;
Date x;
try {
String d = this.getDefaultConnector().getFieldById(urlHash, CollectionSchema.load_date_dt.getSolrFieldName());
SolrDocument doc = this.getDefaultConnector().getDocumentById(urlHash, CollectionSchema.load_date_dt.getSolrFieldName());
Object d = doc == null ? null : doc.getFieldValue(CollectionSchema.load_date_dt.getSolrFieldName());
if (d == null) return null;
x = new Date(Long.parseLong(d));
assert d instanceof Date : "d = " + d.toString();
if (d instanceof Date) return (Date) d;
if (d instanceof Long) return new Date(((Long) d).longValue());
return null;
} catch (final IOException e) {
return null;
}
return x;
}
public DigestURL getURL(final byte[] urlHash) {
if (urlHash == null || this.getDefaultConnector() == null) return null;
String x;
try {
x = this.getDefaultConnector().getFieldById(ASCII.String(urlHash), CollectionSchema.sku.getSolrFieldName());
} catch (final IOException e) {
SolrDocument doc = this.getDefaultConnector().getDocumentById(ASCII.String(urlHash), CollectionSchema.sku.getSolrFieldName());
Object u = doc == null ? null : doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());
if (u == null) return null;
assert u instanceof String : "u = " + u.toString();
if (u instanceof String) return new DigestURL((String) u, urlHash);
return null;
}
if (x == null) return null;
try {
DigestURL uri = new DigestURL(x, urlHash);
return uri;
} catch (final MalformedURLException e) {
} catch (final IOException e) {
return null;
}
}
@ -645,9 +644,10 @@ public final class Fulltext {
public String failReason(final String urlHash) throws IOException {
if (urlHash == null) return null;
String reason = this.getDefaultConnector().getFieldById(urlHash, CollectionSchema.failreason_s.getSolrFieldName());
SolrDocument doc = this.getDefaultConnector().getDocumentById(urlHash, CollectionSchema.failreason_s.getSolrFieldName());
Object reason = doc == null ? null : doc.getFieldValue(CollectionSchema.failreason_s.getSolrFieldName());
if (reason == null) return null;
return reason.length() == 0 ? null : reason;
return reason instanceof String && ((String) reason).length() == 0 ? null : (String) reason;
}
public List<File> dumpFiles() {

Loading…
Cancel
Save