/** Get the first value for a field. * * @param name name of the field to fetch * @return first value of the field or null if not present */ public Object getFieldValue(String name) { SolrInputField field = getField(name); Object o = null; if (field!=null) o = field.getFirstValue(); return o; }
/** Get the first value for a field. * * @param name name of the field to fetch * @return first value of the field or null if not present */ public Object getFieldValue(String name) { SolrInputField field = getField(name); Object o = null; if (field!=null) o = field.getFirstValue(); return o; }
/** * * @return */ public String getHost() { return (String) getField(SolrFields.SOLR_HOST).getFirstValue(); }
/** * * @return */ public String getWaybackDate() { return (String) getField(SolrFields.WAYBACK_DATE).getFirstValue(); }
/** * * @return */ public String getHash() { return (String) getField(SolrFields.HASH).getFirstValue(); }
/** Get the first value for a field. * * @param name name of the field to fetch * @return first value of the field or null if not present */ @Override public Object getFieldValue(String name) { SolrInputField field = getField(name); Object o = null; if (field!=null) o = field.getFirstValue(); return o; }
/** * * @return */ public String getUrl() { return (String) getField(SolrFields.SOLR_URL).getFirstValue(); }
/** * * @return */ public String getWaybackDate() { return (String) getField(SolrFields.WAYBACK_DATE).getFirstValue(); }
/** * * @return */ public String getHash() { return (String) getField(SolrFields.HASH).getFirstValue(); } }
/** * * @return */ public String getUrl() { return (String) getField(SolrFields.SOLR_URL).getFirstValue(); }
@Override public int compare(SolrInputDocument doc1, SolrInputDocument doc2) { SolrInputField f1 = doc1.getField(fieldName); SolrInputField f2 = doc2.getField(fieldName); if (f1 == f2) { return 0; } else if (f1 == null) { return -1; } else if (f2 == null) { return 1; } Object v1 = f1.getFirstValue(); Object v2 = f2.getFirstValue(); return child.compare(v1, v2); }
@Override public int compare(SolrInputDocument doc1, SolrInputDocument doc2) { SolrInputField f1 = doc1.getField(fieldName); SolrInputField f2 = doc2.getField(fieldName); if (f1 == f2) { return 0; } else if (f1 == null) { return -1; } else if (f2 == null) { return 1; } Object v1 = f1.getFirstValue(); Object v2 = f2.getFirstValue(); return child.compare(v1, v2); }
/** * Get a string containing the format as determined by three different * techniques: * * @return */ public String getFormatResults() { StringBuilder sb = new StringBuilder(); // As Served: SolrInputField served = getField(SolrFields.CONTENT_TYPE_SERVED); if (served != null) { sb.append((String) served.getFirstValue()); } // Tika: sb.append("\t"); SolrInputField tika = getField(SolrFields.CONTENT_TYPE_TIKA); if (tika != null) { sb.append((String) tika.getFirstValue()); } // DROID: sb.append("\t"); SolrInputField droid = getField(SolrFields.CONTENT_TYPE_DROID); if (droid != null) { sb.append((String) droid.getFirstValue()); } return sb.toString(); }
/** * Write the document to the solr index * * @param doc the solr document * @throws IOException if IO error */ protected void writeDocument(SolrInputDocument doc) throws IOException { try { getSolr().add(doc); } catch (Exception e) { try { log.error("An error occurred for document: " + doc.getField("id").getFirstValue() + ", source: " + doc .getField("source").getFirstValue() + ", field: " + doc.getField("field") .getFirstValue() + ", full-text: " + doc .getField("full-text").getFirstValue(), e); } catch (Exception e1) { //shouldn't happen } log.error(e.getMessage(), e); } }
/** * Run all configured analysers on the text. * * @param text * @param solr */ public void analyse( SolrRecord solr ) { final long start = System.nanoTime(); // Pull out the text: if( solr.getField( SolrFields.SOLR_EXTRACTED_TEXT ) != null ) { String text = ( String ) solr.getField( SolrFields.SOLR_EXTRACTED_TEXT ).getFirstValue(); text = text.trim(); if( !"".equals( text ) ) { for( AbstractTextAnalyser ta : analysers ) { ta.analyse(text, solr); } } } Instrument.timeRel("WARCIndexer.extract#total", "TextAnalyzers#total", start); }
/** * Run all configured analysers on the text. * * @param text * @param solr */ public void analyse( SolrRecord solr ) { final long start = System.nanoTime(); // Pull out the text: if( solr.getField( SolrFields.SOLR_EXTRACTED_TEXT ) != null ) { String text = ( String ) solr.getField( SolrFields.SOLR_EXTRACTED_TEXT ).getFirstValue(); text = text.trim(); if( !"".equals( text ) ) { for( AbstractTextAnalyser ta : analysers ) { if (ta.isEnabled()) { ta.analyse(text, solr); } } } } Instrument.timeRel("WARCIndexer.extract#total", "TextAnalyzers#total", start); }
/** * Add a SolrInputDocument to this writer. * <p> * Adding multiple documents without ids will result in an IllegalStateException being thrown. */ @Override public void add(SolrInputDocument solrDocument) { String docId = documentId; SolrInputField uniqueKeySolrField = solrDocument.getField(uniqueKeyField); if (uniqueKeySolrField == null || uniqueKeySolrField.getValueCount() == 0) { if (idUsed) { throw new IllegalStateException("Document id '" + documentId + "' has already been used by this record"); } solrDocument.addField(uniqueKeyField, documentId); idUsed = true; } else if (LEGACY_MODE) { docId = uniqueKeySolrField.getValue().toString(); } else { docId = uniqueKeySolrField.getFirstValue().toString(); } if (tableNameField != null) { solrDocument.addField(tableNameField, tableName); } updateCollector.add(docId, solrDocument); }
public String getPrintableId(IndexSchema schema) { SchemaField sf = schema.getUniqueKeyField(); if (indexedId != null) { return schema.getUniqueKeyField().getType().indexedToReadable(indexedId); } if (doc != null) { return schema.printableUniqueKey(doc); } if (solrDoc != null) { SolrInputField field = solrDoc.getField(sf.getName()); if (field != null) { return field.getFirstValue().toString(); } } return "(null)"; }
public String getIndexedId(IndexSchema schema) { if (indexedId == null) { SchemaField sf = schema.getUniqueKeyField(); if (sf != null) { if (doc != null) { schema.getUniqueKeyField(); Field storedId = doc.getField(sf.getName()); indexedId = sf.getType().storedToIndexed(storedId); } if (solrDoc != null) { SolrInputField field = solrDoc.getField(sf.getName()); if (field != null) { indexedId = sf.getType().toInternal( field.getFirstValue().toString() ); } } } } return indexedId; }
m.put(f, v.getFirstValue());