entry = new HashMap<String, ByteIterator>((int) results.getNumFound()); for (String field : hit.getFieldNames()) { entry.put(field, new StringByteIterator(String.valueOf(hit.getFirstValue(field))));
entry = new HashMap<>((int) results.getNumFound()); for (String field : hit.getFieldNames()) { entry.put(field, new StringByteIterator(String.valueOf(hit.getFirstValue(field))));
for (String field : results.get(0).getFieldNames()) { result.put(field, new StringByteIterator(String.valueOf(results.get(0).getFirstValue(field))));
for (String field : results.get(0).getFieldNames()) { result.put(field, new StringByteIterator(String.valueOf(results.get(0).getFirstValue(field))));
/** Get the field Value */ @Override public Object get(Object key) { return getFirstValue( (String)key ); }
@Override public String getDescription() { return this.doc != null ? (String) this.doc.getFirstValue(DEF) : null; }
@Override public String getId() { return this.doc != null ? (String) this.doc.getFirstValue(ID) : null; }
@Override public String getName() { return this.doc != null ? (String) this.doc.getFirstValue(NAME) : null; }
/** Get the field Value */ @Override public Object get(Object key) { return getFirstValue( (String)key ); }
/** Get the field Value */ public Object get(Object key) { return getFirstValue( (String)key ); }
private static DSpaceObject findDSpaceObject(Context context, SolrDocument doc) throws SQLException { Integer type = (Integer) doc.getFirstValue("search.resourcetype"); Integer id = (Integer) doc.getFirstValue("search.resourceid"); String handle = (String) doc.getFirstValue("handle"); if (type != null && id != null) { return DSpaceObject.find(context, type, id); } else if (handle != null) { return HandleManager.resolveToObject(context, handle); } return null; }
/** * @see org.opencms.search.I_CmsSearchDocument#getScore() */ public float getScore() { Float score = (Float)getSolrDocument().getFirstValue(CmsSearchField.FIELD_SCORE); if (score != null) { m_score = score.floatValue(); return m_score; } return 0F; }
private static String getFirst(SolrDocument doc, SolrName field) { return (String) doc.getFirstValue(field.solrName()); }
/** * Find DSpace object by type and UUID or by handle from given Solr document * * @param context The relevant DSpace Context. * @param doc the solr document * @return DSpace object * @throws SQLException An exception that provides information on a database access error or other errors. */ protected DSpaceObject findDSpaceObject(Context context, SolrDocument doc) throws SQLException { Integer type = (Integer) doc.getFirstValue(RESOURCE_TYPE_FIELD); UUID id = UUID.fromString((String) doc.getFirstValue(RESOURCE_ID_FIELD)); String handle = (String) doc.getFirstValue(HANDLE_FIELD); if (type != null && id != null) { return contentServiceFactory.getDSpaceObjectService(type).find(context, id); } else if (handle != null) { return handleService.resolveToObject(context, handle); } return null; }
private String getFieldFirstStringValue(SolrDocument solrDocument, String fieldName) { Object field = solrDocument.getFirstValue(fieldName); if (field instanceof Field) { return ((Field) field).stringValue(); } else if (field instanceof IndexableField) { return ((IndexableField) field).stringValue(); } return field != null ? field.toString() : null; }
@Override public int process(List<SolrDocument> batch) throws ClassifierException { for (SolrDocument topicEntry : batch) { String conceptId = topicEntry.getFirstValue(conceptUriField).toString(); Collection<Object> broader = topicEntry.getFieldValues(broaderField); if (broader == null) { classifier.addConcept(conceptId, null, null); } else { List<String> broaderConcepts = new ArrayList<String>(); for (Object broaderConcept : broader) { broaderConcepts.add(broaderConcept.toString()); } classifier.addConcept(conceptId, null, broaderConcepts); } } return batch.size(); } });
@Override public int process(List<SolrDocument> batch) throws ClassifierException { for (SolrDocument topicEntry : batch) { String conceptId = topicEntry.getFirstValue(conceptUriField).toString(); Collection<Object> broader = topicEntry.getFieldValues(broaderField); if (broader == null) { classifier.addConcept(conceptId, null, null); } else { List<String> broaderConcepts = new ArrayList<String>(); for (Object broaderConcept : broader) { broaderConcepts.add(broaderConcept.toString()); } classifier.addConcept(conceptId, null, broaderConcepts); } } return batch.size(); } });
private NodeInfo getNextDocument (SolrDocumentList docs) { // FIXME: test pagination I think there is a bug here if w/start > 0? SolrDocument doc = docs.get(position++ - (int) docs.getStart()); String uri = (String) doc.getFirstValue(uriFieldName); Object oxml = doc.getFirstValue(xmlFieldName); Long id = (Long) doc.getFirstValue(idFieldName); if (id == null) { // try to support migrating an old index? throw new LuxException("This index has no lux docids: it cannot support Lux on Solr Cloud"); } String xml = (String) ((oxml instanceof String) ? oxml : null); byte [] bytes = (byte[]) ((oxml instanceof byte[]) ? oxml : null); XdmNode node = eval.getDocReader().createXdmNode(id, uri, xml, bytes); DocumentInfo docNode = node.getUnderlyingNode().getDocumentRoot(); docNode.setUserData(SolrDocument.class.getName(), doc); return docNode; }
private static DcsEvent getEvent(SolrDocument doc) { DcsEvent event = new DcsEvent(); event.setId(getFirst(doc, EntityField.ID)); Date date = (Date) doc.getFirstValue(EventField.DATE.solrName()); if (date != null) { event.setDate(DateUtil.getThreadLocalDateFormat().format(date)); } event.setDetail(getFirst(doc, EventField.DETAIL)); event.setOutcome(getFirst(doc, EventField.OUTCOME)); event.setEventType(getFirst(doc, EventField.TYPE)); event.setTargets(getEntityRefSet(doc, EventField.TARGET)); event.setAlternateIds(getResourceIdentifierSet(doc)); return event; }
@Test public void testLoadSolrWithChildDocuments() throws Exception { morphline = createMorphline("test-morphlines" + File.separator + "loadSolrWithChildDocuments"); Record record = new Record(); record.put(Fields.ID, "id0"); startSession(); Notifications.notifyBeginTransaction(morphline); assertTrue(morphline.process(record)); assertEquals(1, collector.getNumStartEvents()); Notifications.notifyCommitTransaction(morphline); // This parent block join returns the parent records for records // where the child documents contain "bar" in the id field. SolrDocumentList docs = query("{!parent which='content_type:parent'}id:bar").getResults(); assertEquals(1, docs.size()); assertEquals("id0", docs.get(0).getFirstValue(Fields.ID)); docs = query("*:*").getResults(); assertEquals(3, docs.size()); }