/** * Ajoute un champs dans un document a indexer */ protected void addToIndexDocument(SolrInputDocument doc, WikittyTypes type, String fqfieldName, Object fieldValue, boolean collection) { if (fqfieldName.startsWith(SOLR_WIKITTY_PREFIX)) { doc.remove(fqfieldName); doc.addField(fqfieldName, fieldValue); } else { String solrFqFieldName; // add suffix like _s for string type ex: myExt.myField_s solrFqFieldName = SolrUtil.getSolrFieldName(fqfieldName, type); String solrNullFieldFqFieldName = SOLR_NULL_FIELD + fqfieldName; doc.remove(solrFqFieldName); // myExt.myField_s doc.remove(solrNullFieldFqFieldName); // #null_field-myExt.myField String solrNullFieldFqFieldNameValue = "true"; if(fieldValue != null) { doc.addField(solrFqFieldName, fieldValue); solrNullFieldFqFieldNameValue = "false"; if (log.isTraceEnabled()) { log.trace(String.format("index field '%s' with value '%s'", solrFqFieldName, StringUtils.abbreviate(String.valueOf(fieldValue), 50))); } } doc.addField(solrNullFieldFqFieldName, solrNullFieldFqFieldNameValue); } }
solrResource.addDoc(attId, doc); doc.remove(TREENODE_ATTACHED + treeNodeId);
solrResource.addDoc(attId, doc); doc.remove(TREENODE_ATTACHED + treeNodeId);
protected void addToIndexDocument(SolrInputDocument doc, TYPE type, String fqfieldName, Object fieldValue) { if (fqfieldName.startsWith(SOLR_WIKITTY_PREFIX)) { doc.remove(fqfieldName); doc.addField(fqfieldName, fieldValue); } else { doc.remove(solrFqFieldName); doc.remove(solrNullFieldFqFieldName); doc.remove(solrAllFieldName);
private static SolrInputDocument validateDescriptiveMetadataFields(SolrInputDocument doc) { if (doc.get(RodaConstants.AIP_DATE_INITIAL) != null) { Object value = doc.get(RodaConstants.AIP_DATE_INITIAL).getValue(); if (value instanceof String) { try { Date d = parseDate((String) value); doc.setField(RodaConstants.AIP_DATE_INITIAL, d); } catch (ParseException pe) { doc.remove(RodaConstants.AIP_DATE_INITIAL); doc.setField(RodaConstants.AIP_DATE_INITIAL + "_txt", value); } } } if (doc.get(RodaConstants.AIP_DATE_FINAL) != null) { Object value = doc.get(RodaConstants.AIP_DATE_FINAL).getValue(); if (value instanceof String) { try { Date d = parseDate((String) value); doc.setField(RodaConstants.AIP_DATE_FINAL, d); } catch (ParseException pe) { doc.remove(RodaConstants.AIP_DATE_FINAL); doc.setField(RodaConstants.AIP_DATE_FINAL + "_txt", value); } } } return doc; }
private int updateRecords(String query) throws SolrServerException, SQLException, IOException { int initNumProcessed = numProcessed; SolrQuery sQ = new SolrQuery(); sQ.setQuery(query); sQ.setRows(batchSize); // Ensure that items are grouped by id // Sort by id fails due to presense of id and string fields. The ord function // seems to help sQ.addSort("type", SolrQuery.ORDER.desc); sQ.addSort("scopeType", SolrQuery.ORDER.desc); sQ.addSort("ord(owningItem)", SolrQuery.ORDER.desc); sQ.addSort("id", SolrQuery.ORDER.asc); sQ.addSort("scopeId", SolrQuery.ORDER.asc); QueryResponse sr = server.query(sQ); SolrDocumentList sdl = sr.getResults(); for (int i = 0; i < sdl.size() && (numProcessed < numRec); i++) { SolrDocument sd = sdl.get(i); SolrInputDocument input = ClientUtils.toSolrInputDocument(sd); input.remove("_version_"); for (FIELD col : FIELD.values()) { mapField(input, col); } docs.add(input); ++numProcessed; } return numProcessed - initNumProcessed; }