document.addField(solrPropertyName, value); } else { document.setField(solrPropertyName, value);
/** Set a field with implied null value for boost. * * @see #setField(String, Object, float) * @param name name of the field to set * @param value value of the field */ public void setField(String name, Object value) { setField(name, value, 1.0f ); }
/** Set a field with implied null value for boost. * * @see #setField(String, Object, float) * @param name name of the field to set * @param value value of the field */ public void setField(String name, Object value) { setField(name, value, 1.0f ); }
@Override public void setField(String name, Object value, float boost) { super.setField(name, value, boost); if (value instanceof String) { this.length += ((String) value).length(); } else if (value instanceof byte[]) { this.length += ((byte[]) value).length; } // TODO: support more type ? } }
/** * @see org.opencms.search.I_CmsSearchDocument#addContentField(byte[]) */ public void addContentField(byte[] data) { m_doc.setField(CmsSearchField.FIELD_CONTENT_BLOB, ByteBuffer.wrap(data)); }
public SolrInputDocument build() throws InterruptedException, RepositoryException { solrDoc.setField("lily.id", recordId.toString()); solrDoc.setField("lily.table", table); solrDoc.setField("lily.key", key); solrDoc.setField("lily.vtagId", vtag.toString()); solrDoc.setField("lily.vtag", typeManager.getFieldTypeById(vtag).getName().getName()); solrDoc.setField("lily.version", version); return solrDoc; }
/** * Set the field, truncating the value if it's larger than the given limit. * * @param solr_property * @param value * @param truncateTo */ public void setFieldTruncated(String solr_property, String value, int truncateTo) { value = sanitizeString(value, truncateTo); if (value != null && !value.isEmpty()) doc.setField(solr_property, value); }
@Override public SolrInputDocument convertTuple(Map<String, Object> tupleFields) { SolrInputDocument inputDoc = new SolrInputDocument(); Iterator<Entry<String, Object>> itr = tupleFields.entrySet().iterator(); while (itr.hasNext()) { Entry<String, Object> field = itr.next(); inputDoc.setField(field.getKey(), field.getValue()); } return inputDoc; }
public boolean indexQuestion(int qid, String title, String content) throws IOException, SolrServerException { SolrInputDocument doc = new SolrInputDocument(); doc.setField("id", qid); doc.setField(QUESTION_TITLE_FIELD, title); doc.setField("QUESTION_CONTENT_FIELD", content); UpdateResponse response = client.add(doc, 1000); return response != null && response.getStatus() == 0; } }
@Override public void inject(final SolrInputDocument document, final Object value) { final Calendar calendar = ((XSDDateTime)value).asCalendar(); final long millis = calendar.getTimeInMillis(); document.setField( Field.DATE_OBJECT, new Date(millis + calendar.getTimeZone().getOffset(millis))); }
/** * Set the field, truncating the value if it's larger than the given limit. * * @param solr_property * @param value * @param truncateTo */ public void setFieldTruncated(String solr_property, String value, int truncateTo) { value = sanitizeString(value, truncateTo); if (value != null && !value.isEmpty()) doc.setField(solr_property, value); }
@Override public SolrInputDocument convertTuple(Map<String, Object> tupleFields) { SolrInputDocument inputDoc = new SolrInputDocument(); Iterator<Entry<String, Object>> itr = tupleFields.entrySet().iterator(); while (itr.hasNext()) { Entry<String, Object> field = itr.next(); inputDoc.setField(field.getKey(), field.getValue()); } return inputDoc; }
private SolrInputDocument convert(Record record) { Map<String, Collection<Object>> map = record.getFields().asMap(); SolrInputDocument doc = new SolrInputDocument(new HashMap(2 * map.size())); for (Map.Entry<String, Collection<Object>> entry : map.entrySet()) { doc.setField(entry.getKey(), entry.getValue()); } return doc; }
public SolrInputDocument toSolrInputDocument( Object obj ) { List<DocField> fields = getDocFields( obj.getClass() ); if( fields.isEmpty() ) { throw new RuntimeException( "class: "+obj.getClass()+" does not define any fields." ); } SolrInputDocument doc = new SolrInputDocument(); for( DocField field : fields ) { doc.setField( field.name, field.get( obj ), 1.0f ); } return doc; }
private SolrInputDocument convert(Record record) { Map<String, Collection<Object>> map = record.getFields().asMap(); SolrInputDocument doc = new SolrInputDocument(new HashMap(2 * map.size())); for (Map.Entry<String, Collection<Object>> entry : map.entrySet()) { String key = entry.getKey(); doc.setField(key, entry.getValue(), getBoost(key)); } return doc; }
private SolrInputDocument convert(Record record) { Map<String, Collection<Object>> map = record.getFields().asMap(); SolrInputDocument doc = new SolrInputDocument(new HashMap(2 * map.size())); for (Map.Entry<String, Collection<Object>> entry : map.entrySet()) { String key = entry.getKey(); doc.setField(key, entry.getValue(), getBoost(key)); } return doc; }
private void convertId(Author contribution, SolrInputDocument doc) { String id = contribution.getDocId() + "_" + contribution.getPositionNumber(); doc.setField(SolrIndexConstants.CONTRIBUTION_ID_FIELD_NAME, id); }
private void convertDocYear(DocumentWrapper dw, SolrInputDocument doc) { String year = dw.getDocumentMetadata().getBasicMetadata().getYear(); doc.setField(SolrIndexConstants.CONTRIBUTION_DOCYEAR_FIELD_NAME, year); } }
public void addDocument(Map<String, Object> fields) throws Exception { SolrInputDocument doc = new SolrInputDocument(); for (String field : fields.keySet()) { doc.setField(field, fields.get(field)); } server.add(doc, 100); }