org.apache.solr.common.SolrInputDocument Java Examples
The following examples show how to use
org.apache.solr.common.SolrInputDocument.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SolrIndex.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
private void deleteIndividualFieldsFromIndex(String collectionName, String keyIdField, String docId, HashSet<IndexEntry> fieldDeletions) throws SolrServerException, IOException { if (fieldDeletions.isEmpty()) return; Map<String, String> fieldDeletes = new HashMap<String, String>(1) {{ put("set", null); }}; SolrInputDocument doc = new SolrInputDocument(); doc.addField(keyIdField, docId); StringBuilder sb = new StringBuilder(); for (IndexEntry fieldToDelete : fieldDeletions) { doc.addField(fieldToDelete.field, fieldDeletes); sb.append(fieldToDelete).append(","); } if (logger.isTraceEnabled()) logger.trace("Deleting individual fields [{}] for document {}", sb.toString(), docId); UpdateRequest singleDocument = newUpdateRequest(); singleDocument.add(doc); solrClient.request(singleDocument, collectionName); }
Example #2
Source File: MCRSolrAltoExtractor.java From mycore with GNU General Public License v3.0 | 6 votes |
private void extract(Element root, SolrInputDocument document) { StringBuilder altoContent = new StringBuilder(); for (Element stringElement : STRING_EXP.evaluate(root)) { String content = stringElement.getAttributeValue("CONTENT"); String hpos = stringElement.getAttributeValue("HPOS"); String vpos = stringElement.getAttributeValue("VPOS"); String width = stringElement.getAttributeValue("WIDTH"); String height = stringElement.getAttributeValue("HEIGHT"); if (hpos == null || vpos == null || width == null || height == null) { continue; } String regEx = "\\.0"; String altoWord = String.join("|", content, hpos.replaceAll(regEx, ""), vpos.replaceAll(regEx, ""), width.replaceAll(regEx, ""), height.replaceAll(regEx, "")); altoContent.append(content).append(' '); document.addField("alto_words", altoWord); } document.addField("alto_content", altoContent.toString().trim()); }
Example #3
Source File: JsonLoaderTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testIntegerValuesInAdd() throws Exception { String str = "{'add':[{'id':'1','i1':256,'i2':-5123456789,'i3':[0,1]}]}".replace('\'', '"'); SolrQueryRequest req = req(); SolrQueryResponse rsp = new SolrQueryResponse(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); JsonLoader loader = new JsonLoader(); loader.load(req, rsp, new ContentStreamBase.StringStream(str), p); assertEquals(1, p.addCommands.size()); AddUpdateCommand add = p.addCommands.get(0); SolrInputDocument d = add.solrDoc; SolrInputField f = d.getField("i1"); assertEquals(256L, f.getValue()); f = d.getField("i2"); assertEquals(-5123456789L, f.getValue()); f = d.getField("i3"); assertEquals(2, ((List)f.getValue()).size()); assertEquals(0L, ((List)f.getValue()).get(0)); assertEquals(1L, ((List)f.getValue()).get(1)); req.close(); }
Example #4
Source File: SolrSearchServerTest.java From vind with Apache License 2.0 | 6 votes |
@Before public void init() throws IOException, SolrServerException { MockitoAnnotations.initMocks(this); when(solrClient.ping()).thenReturn(solrPingResponse); when(solrPingResponse.getStatus()).thenReturn(0); when(solrPingResponse.getQTime()).thenReturn(10); when(solrClient.query(any(), any(SolrRequest.METHOD.class))).thenReturn(response); when(response.getResults()).thenReturn(new SolrDocumentList()); when(response.getResults()).thenReturn(new SolrDocumentList()); when(solrClient.add(org.mockito.Matchers.<Collection<SolrInputDocument>>any())).thenReturn(iResponse); when(solrClient.add(any(SolrInputDocument.class))).thenReturn(iResponse); when(iResponse.getQTime()).thenReturn(10); when(iResponse.getElapsedTime()).thenReturn(15l); //we use the protected constructor to avoid schema checking server = new SolrSearchServer(solrClient, false); }
Example #5
Source File: TestSolrJErrorHandling.java From lucene-solr with Apache License 2.0 | 6 votes |
Iterator<SolrInputDocument> manyDocs(final int base, final int numDocs) { return new Iterator<SolrInputDocument>() { int count = 0; @Override public boolean hasNext() { return count < numDocs; } @Override public SolrInputDocument next() { int id = base + count++; if (count == 1) { // first doc is legit, and will increment a counter return sdoc("id","test", "count_i", map("inc",1)); } // include "ignore_exception" so the log doesn't fill up with known exceptions, and change the values for each doc // so binary format won't compress too much return sdoc("id",Integer.toString(id),"ignore_exception_field_does_not_exist_"+id,"fieldval"+id); } @Override public void remove() { } }; }
Example #6
Source File: TestTlogReplayVsRecovery.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Adds the specified number of docs directly to the leader, * using increasing docIds begining with startId. Commits if and only if the boolean is true. */ private void addDocs(final boolean commit, final int numDocs, final int startId) throws SolrServerException, IOException { List<SolrInputDocument> docs = new ArrayList<>(numDocs); for (int i = 0; i < numDocs; i++) { int id = startId + i; docs.add(new SolrInputDocument("id", String.valueOf(id), "fieldName_s", String.valueOf(id))); } // For simplicity, we always add out docs directly to NODE0 // (where the leader should be) and bypass the proxy... try (HttpSolrClient client = getHttpSolrClient(NODE0.getBaseUrl().toString())) { assertEquals(0, client.add(COLLECTION, docs).getStatus()); if (commit) { assertEquals(0, client.commit(COLLECTION).getStatus()); } } }
Example #7
Source File: ParsingFieldUpdateProcessorsTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testParseAlternateValueBooleans() throws Exception { IndexSchema schema = h.getCore().getLatestSchema(); assertNotNull(schema.getFieldOrNull("boolean1_b")); // should match dynamic field "*_b" assertNotNull(schema.getFieldOrNull("boolean2_b")); // should match dynamic field "*_b" assertNotNull(schema.getFieldOrNull("boolean3_b")); // should match dynamic field "*_b" assertNotNull(schema.getFieldOrNull("boolean4_b")); // should match dynamic field "*_b" assertNotNull(schema.getFieldOrNull("boolean5_b")); // should match dynamic field "*_b" assertNull(schema.getFieldOrNull("not_in_schema")); boolean[] values = { true, true, true, false, false, false }; String[] stringValues = { "on", "yes", "True", "Off", "no", "FALSE" }; String[] fieldNames = { "boolean1_b", "boolean2_b", "boolean3_b", "boolean4_b", "boolean5_b", "not_in_schema" }; SolrInputDocument d = doc(f("id", "55")); for (int i = 0 ; i < values.length ; ++i) { d.addField(fieldNames[i], stringValues[i]); } d = processAdd("parse-boolean-alternate-values-no-run-processor", d); assertNotNull(d); for (int i = 0 ; i < values.length ; ++i) { assertThat(d.getFieldValue(fieldNames[i]), IS_BOOLEAN); assertEquals(values[i], d.getFieldValue(fieldNames[i])); } }
Example #8
Source File: ParsingFieldUpdateProcessorsTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testFailedParseMixedBoolean() throws Exception { IndexSchema schema = h.getCore().getLatestSchema(); assertNull(schema.getFieldOrNull("not_in_schema")); Map<Object,Object> mixed = new HashMap<>(); Long longVal = 294423L; mixed.put(true, "true"); mixed.put(longVal, longVal); // Float-typed field value mixed.put(false, "false"); mixed.put(true, "true"); SolrInputDocument d = processAdd("parse-boolean-no-run-processor", doc(f("id", "7207"), f("not_in_schema", mixed.values()))); assertNotNull(d); boolean foundLong = false; for (Object o : d.getFieldValues("not_in_schema")) { if (longVal == o) { foundLong = true; } else { assertThat(o, IS_STRING); } mixed.values().remove(o); } assertTrue(foundLong); assertTrue(mixed.isEmpty()); }
Example #9
Source File: TextIndexSolr5.java From BioSolr with Apache License 2.0 | 6 votes |
private SolrInputDocument solrDoc(Entity entity) { SolrInputDocument doc = new SolrInputDocument() ; doc.addField(docDef.getEntityField(), entity.getId()) ; String graphField = docDef.getGraphField() ; if ( graphField != null ) { doc.addField(graphField, entity.getGraph()) ; } // the addition needs to be done as a partial update // otherwise, if we have multiple fields, each successive // addition will replace the previous one and we are left // with only the last field indexed. // see // http://stackoverflow.com/questions/12183798/solrj-api-for-partial-document-update // and // https://svn.apache.org/repos/asf/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java HashMap<String, Object> map = new HashMap<>() ; for ( Map.Entry<String, Object> e : entity.getMap().entrySet() ) { map.put("add", e.getValue()) ; doc.addField(e.getKey(), map) ; } return doc ; }
Example #10
Source File: CdcrBootstrapTest.java From lucene-solr with Apache License 2.0 | 6 votes |
private int indexDocs(CloudSolrClient sourceSolrClient, String collection, int batches) throws IOException, SolrServerException { sourceSolrClient.setDefaultCollection(collection); int numDocs = 0; for (int k = 0; k < batches; k++) { UpdateRequest req = new UpdateRequest(); for (; numDocs < (k + 1) * 100; numDocs++) { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "source_" + numDocs); doc.addField("xyz", numDocs); req.add(doc); } req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); req.process(sourceSolrClient); } log.info("Adding numDocs={}", numDocs); return numDocs; }
Example #11
Source File: FieldMutatingUpdateProcessorTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testTrimRegex() throws Exception { SolrInputDocument d = null; d = processAdd("trim-field-regexes", doc(f("id", "1111"), f("foo_t", " string1 "), f("foozat_s", " string2 "), f("bar_t", " string3 "), f("bar_s", " string4 "))); assertNotNull(d); assertEquals("string1", d.getFieldValue("foo_t")); assertEquals("string2", d.getFieldValue("foozat_s")); assertEquals(" string3 ", d.getFieldValue("bar_t")); assertEquals("string4", d.getFieldValue("bar_s")); }
Example #12
Source File: ParsingFieldUpdateProcessorsTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testParseBooleanRoundTrip() throws Exception { IndexSchema schema = h.getCore().getLatestSchema(); assertNotNull(schema.getFieldOrNull("boolean1_b")); // should match dynamic field "*_b" assertNotNull(schema.getFieldOrNull("boolean2_b")); // should match dynamic field "*_b" boolean value1 = true; boolean value2 = false; SolrInputDocument d = processAdd("parse-boolean", doc(f("id", "141"), f("boolean1_b", value1), f("boolean2_b", value2))); assertNotNull(d); assertThat(d.getFieldValue("boolean1_b"), IS_BOOLEAN); assertEquals(value1, d.getFieldValue("boolean1_b")); assertThat(d.getFieldValue("boolean2_b"), IS_BOOLEAN); assertEquals(value2, d.getFieldValue("boolean2_b")); assertU(commit()); assertQ(req("id:141") ,"//bool[@name='boolean1_b'][.='" + value1 + "']" ,"//bool[@name='boolean2_b'][.='" + value2 + "']"); }
Example #13
Source File: MCRSolrInputDocumentGenerator.java From mycore with GNU General Public License v3.0 | 6 votes |
public static SolrInputDocument getSolrInputDocument(Element input) { SolrInputDocument doc = new SolrInputDocument(); HashSet<MCRSolrInputField> duplicateFilter = new HashSet<>(); List<Element> fieldElements = input.getChildren("field"); for (Element fieldElement : fieldElements) { MCRSolrInputField field = new MCRSolrInputField(); field.setName(fieldElement.getAttributeValue("name")); field.setValue(fieldElement.getText()); if (field.getValue().isEmpty() || duplicateFilter.contains(field)) { continue; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("adding {}={}", field.getName(), field.getValue()); } duplicateFilter.add(field); doc.addField(field.getName(), field.getValue()); } List<Element> docElements = input.getChildren("doc"); for (Element child : docElements) { SolrInputDocument solrChild = getSolrInputDocument(child); doc.addChildDocument(solrChild); } return doc; }
Example #14
Source File: SolrExampleTests.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * recursive method for generating a document, which may also have child documents; * adds all documents constructed (including decendents) to allDocs via their id */ private SolrInputDocument genNestedDocuments(Map<String,SolrInputDocument> allDocs, int thisLevel, int maxDepth) { String id = "" + (idCounter++); SolrInputDocument sdoc = new SolrInputDocument(); allDocs.put(id, sdoc); sdoc.addField("id", id); sdoc.addField("level_i", thisLevel); sdoc.addField("name", names[TestUtil.nextInt(random(), 0, names.length-1)]); if (0 < maxDepth) { // NOTE: range include negative to increase odds of no kids int numKids = TestUtil.nextInt(random(), -2, 7); for(int i=0; i<numKids; i++) { sdoc.addChildDocument(genNestedDocuments(allDocs, thisLevel+1, maxDepth-1)); } } return sdoc; }
Example #15
Source File: ParsingFieldUpdateProcessorsTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testMixedFloats() throws Exception { IndexSchema schema = h.getCore().getLatestSchema(); assertNotNull(schema.getFieldOrNull("float_tf")); // should match dynamic field "*_tf" Map<Float,Object> mixedFloats = new HashMap<>(); mixedFloats.put(85.0f, "85"); mixedFloats.put(2894518.0f, "2,894,518"); mixedFloats.put(2.94423E-9f, 2.94423E-9f); // Float-typed field value mixedFloats.put(48794721.937f, "48,794,721.937"); SolrInputDocument d = processAdd("parse-float-no-run-processor", doc(f("id", "342"), f("float_tf", mixedFloats.values()))); assertNotNull(d); for (Object o : d.getFieldValues("float_tf")) { assertThat(o, IS_FLOAT); mixedFloats.remove(o); } assertTrue(mixedFloats.isEmpty()); }
Example #16
Source File: ChaosMonkeySafeLeaderTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override protected void indexr(Object... fields) throws Exception { SolrInputDocument doc = new SolrInputDocument(); addFields(doc, fields); addFields(doc, "rnd_b", true); indexDoc(doc); }
Example #17
Source File: DirectSolrClassicInputDocumentWriter.java From hbase-indexer with Apache License 2.0 | 5 votes |
private void retryAddsIndividually(int shard, Collection<SolrInputDocument> inputDocuments) throws SolrServerException, IOException { for (SolrInputDocument inputDocument : inputDocuments) { try { solrServers.get(shard).add(inputDocument); indexAddMeter.mark(); } catch (SolrException e) { logOrThrowSolrException(e); // No exception thrown through, so we can update the metric documentAddErrorMeter.mark(); } } }
Example #18
Source File: IdAddingSolrUpdateWriterTest.java From hbase-indexer with Apache License 2.0 | 5 votes |
@Test public void testAdd_MultipleDocumentsWithTheirOwnIds() { String idA = DOCUMENT_ID + "A"; String idB = DOCUMENT_ID + "B"; IdAddingSolrUpdateWriter updateWriter = new IdAddingSolrUpdateWriter( UNIQUE_KEY_FIELD, DOCUMENT_ID, null, TABLE_NAME, updateCollector); SolrInputDocument docA = mock(SolrInputDocument.class); SolrInputDocument docB = mock(SolrInputDocument.class); SolrInputField keyFieldA = new SolrInputField(UNIQUE_KEY_FIELD); keyFieldA.setValue(idA, 1.0f); SolrInputField keyFieldB = new SolrInputField(UNIQUE_KEY_FIELD); keyFieldB.setValue(idB, 1.0f); when(docA.getField(UNIQUE_KEY_FIELD)).thenReturn(keyFieldA); when(docB.getField(UNIQUE_KEY_FIELD)).thenReturn(keyFieldB); updateWriter.add(docA); updateWriter.add(docB); verify(updateCollector).add(idA, docA); verify(updateCollector).add(idB, docB); }
Example #19
Source File: SolrIOTestUtils.java From beam with Apache License 2.0 | 5 votes |
/** Inserts the given number of test documents into Solr. */ static void insertTestDocuments(String collection, long numDocs, AuthorizedSolrClient client) throws IOException { List<SolrInputDocument> data = createDocuments(numDocs); try { UpdateRequest updateRequest = new UpdateRequest(); updateRequest.setAction(UpdateRequest.ACTION.COMMIT, true, true); updateRequest.add(data); client.process(collection, updateRequest); } catch (SolrServerException e) { throw new IOException("Failed to insert test documents to collection", e); } }
Example #20
Source File: SystemLogListener.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings({"rawtypes"}) private void addOperations(SolrInputDocument doc, List<SolrRequest> operations) { if (operations == null || operations.isEmpty()) { return; } Set<String> collections = new HashSet<>(); for (SolrRequest req : operations) { SolrParams params = req.getParams(); if (params == null) { continue; } if (params.get(CollectionAdminParams.COLLECTION) != null) { collections.add(params.get(CollectionAdminParams.COLLECTION)); } // build a whitespace-separated param string StringJoiner paramJoiner = new StringJoiner(" "); paramJoiner.setEmptyValue(""); for (Iterator<String> it = params.getParameterNamesIterator(); it.hasNext(); ) { final String name = it.next(); final String [] values = params.getParams(name); for (String value : values) { paramJoiner.add(name + "=" + value); } } String paramString = paramJoiner.toString(); if (!paramString.isEmpty()) { doc.addField("operations.params_ts", paramString); } } if (!collections.isEmpty()) { doc.addField(COLLECTIONS_FIELD, collections); } }
Example #21
Source File: AtomicUpdateDocumentMerger.java From lucene-solr with Apache License 2.0 | 5 votes |
protected void doInc(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal) { SolrInputField numericField = toDoc.get(sif.getName()); SchemaField sf = schema.getField(sif.getName()); if (numericField != null || sf.getDefaultValue() != null) { // TODO: fieldtype needs externalToObject? String oldValS = (numericField != null) ? numericField.getFirstValue().toString(): sf.getDefaultValue().toString(); BytesRefBuilder term = new BytesRefBuilder(); sf.getType().readableToIndexed(oldValS, term); Object oldVal = sf.getType().toObject(sf, term.get()); String fieldValS = fieldVal.toString(); Number result; if (oldVal instanceof Long) { result = ((Long) oldVal).longValue() + Long.parseLong(fieldValS); } else if (oldVal instanceof Float) { result = ((Float) oldVal).floatValue() + Float.parseFloat(fieldValS); } else if (oldVal instanceof Double) { result = ((Double) oldVal).doubleValue() + Double.parseDouble(fieldValS); } else { // int, short, byte result = ((Integer) oldVal).intValue() + Integer.parseInt(fieldValS); } toDoc.setField(sif.getName(), result); } else { toDoc.setField(sif.getName(), fieldVal); } }
Example #22
Source File: AddBlockUpdateTest.java From lucene-solr with Apache License 2.0 | 5 votes |
private void indexSolrInputDocumentsDirectly(SolrInputDocument ... docs) throws IOException { SolrQueryRequest coreReq = new LocalSolrQueryRequest(h.getCore(), new ModifiableSolrParams()); AddUpdateCommand updateCmd = new AddUpdateCommand(coreReq); for (SolrInputDocument doc: docs) { updateCmd.solrDoc = doc; h.getCore().getUpdateHandler().addDoc(updateCmd); updateCmd.clear(); } assertU(commit()); }
Example #23
Source File: NestedAtomicUpdateTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings({"unchecked"}) private static void assertDocContainsSubset(SolrInputDocument subsetDoc, SolrInputDocument fullDoc) { for(SolrInputField field: subsetDoc) { String fieldName = field.getName(); assertTrue("doc should contain field: " + fieldName, fullDoc.containsKey(fieldName)); Object fullValue = fullDoc.getField(fieldName).getValue(); if(fullValue instanceof Collection) { ((Collection) fullValue).containsAll(field.getValues()); } else { assertEquals("docs should have the same value for field: " + fieldName, field.getValue(), fullValue); } } }
Example #24
Source File: DefaultValueUpdateProcessorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Convenience method for building up SolrInputDocuments */ SolrInputDocument doc(SolrInputField... fields) { SolrInputDocument d = new SolrInputDocument(); for (SolrInputField f : fields) { d.put(f.getName(), f); } return d; }
Example #25
Source File: AtomicUpdateProcessorFactory.java From lucene-solr with Apache License 2.0 | 5 votes |
private void processAddWithRetry(AddUpdateCommand cmd, int attempts, SolrInputDocument clonedOriginalDoc) throws IOException { try { super.processAdd(cmd); } catch (SolrException e) { if (attempts++ >= MAX_ATTEMPTS) {//maximum number of attempts allowed: 25 throw new SolrException(SERVER_ERROR, "Atomic update failed after multiple attempts due to " + e.getMessage()); } if (e.code() == ErrorCode.CONFLICT.code) { // version conflict log.warn("Atomic update failed due to {} Retrying with new version .... ({})" , e.getMessage(), attempts); Long lastVersion = vinfo.lookupVersion(cmd.getIndexedId()); // if lastVersion is null then we put -1 to assert that document must not exist lastVersion = lastVersion == null ? -1 : lastVersion; // The AtomicUpdateDocumentMerger modifies the AddUpdateCommand.solrDoc to populate the real values of the // modified fields. We don't want those absolute values because they are out-of-date due to the conflict // so we restore the original document created in processAdd method and set the right version on it cmd.solrDoc = clonedOriginalDoc; clonedOriginalDoc = clonedOriginalDoc.deepCopy(); // copy again because the old cloned ref will be modified during processAdd cmd.solrDoc.setField(VERSION, lastVersion); processAddWithRetry(cmd, attempts, clonedOriginalDoc); } } }
Example #26
Source File: AddUpdateCommand.java From lucene-solr with Apache License 2.0 | 5 votes |
/** Extract all anonymous child documents from parent. */ private void flattenAnonymous(List<SolrInputDocument> unwrappedDocs, SolrInputDocument currentDoc, boolean isRoot) { List<SolrInputDocument> children = currentDoc.getChildDocuments(); if (children != null) { for (SolrInputDocument child : children) { flattenAnonymous(unwrappedDocs, child); } } if(!isRoot) unwrappedDocs.add(currentDoc); }
Example #27
Source File: SolrQuestionIndex.java From mamute with Apache License 2.0 | 5 votes |
private SolrInputDocument toDoc(Question q) { List<String> tagNames = Lists.transform(q.getTags(), new Function<Tag, String>() { @Nullable @Override public String apply(@Nullable Tag tag) { return tag.getName(); } }); SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", q.getId()); doc.addField("title", q.getTitle()); doc.addField("description", q.getMarkedDescription()); doc.addField("tags", join(tagNames)); String solution = null; List<String> answers = new ArrayList<>(); for (Answer a : q.getAnswers()) { if (a.isSolution()) { solution = a.getDescription(); } else { answers.add(a.getDescription()); } } if (solution != null) { doc.addField("solution", solution); } if (answers.size() > 0) { doc.addField("answers", join(answers)); } return doc; }
Example #28
Source File: BaseDistributedSearchTestCase.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Indexes the document in both the control client and the specified client asserting * that the responses are equivalent */ protected UpdateResponse indexDoc(SolrClient client, SolrParams params, SolrInputDocument... sdocs) throws IOException, SolrServerException { UpdateResponse controlRsp = add(controlClient, params, sdocs); UpdateResponse specificRsp = add(client, params, sdocs); compareSolrResponses(specificRsp, controlRsp); return specificRsp; }
Example #29
Source File: SolrJavaIntegration.java From tutorials with MIT License | 5 votes |
public void addSolrDocument(String documentId, String itemName, String itemPrice) throws SolrServerException, IOException { SolrInputDocument document = new SolrInputDocument(); document.addField("id", documentId); document.addField("name", itemName); document.addField("price", itemPrice); solrClient.add(document); solrClient.commit(); }
Example #30
Source File: SolrAuditDestination.java From ranger with Apache License 2.0 | 5 votes |
SolrInputDocument toSolrDoc(AuthzAuditEvent auditEvent) { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", auditEvent.getEventId()); doc.addField("access", auditEvent.getAccessType()); doc.addField("enforcer", auditEvent.getAclEnforcer()); doc.addField("agent", auditEvent.getAgentId()); doc.addField("repo", auditEvent.getRepositoryName()); doc.addField("sess", auditEvent.getSessionId()); doc.addField("reqUser", auditEvent.getUser()); doc.addField("reqData", auditEvent.getRequestData()); doc.addField("resource", auditEvent.getResourcePath()); doc.addField("cliIP", auditEvent.getClientIP()); doc.addField("logType", auditEvent.getLogType()); doc.addField("result", auditEvent.getAccessResult()); doc.addField("policy", auditEvent.getPolicyId()); doc.addField("repoType", auditEvent.getRepositoryType()); doc.addField("resType", auditEvent.getResourceType()); doc.addField("reason", auditEvent.getResultReason()); doc.addField("action", auditEvent.getAction()); doc.addField("evtTime", auditEvent.getEventTime()); doc.addField("seq_num", auditEvent.getSeqNum()); doc.setField("event_count", auditEvent.getEventCount()); doc.setField("event_dur_ms", auditEvent.getEventDurationMS()); doc.setField("tags", auditEvent.getTags()); doc.setField("cluster", auditEvent.getClusterName()); doc.setField("zoneName", auditEvent.getZoneName()); doc.setField("agentHost", auditEvent.getAgentHostname()); doc.setField("policyVersion", auditEvent.getPolicyVersion()); return doc; }