org.apache.solr.common.SolrDocument Java Examples
The following examples show how to use
org.apache.solr.common.SolrDocument.
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: TestCloudPseudoReturnFields.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testFunctions() throws Exception { SolrDocumentList docs = assertSearch(params("q","*:*","rows","1","fl","log(val_i)")); assertEquals(""+docs, 5, docs.getNumFound()); SolrDocument doc = docs.get(0); // doesn't really matter which one assertEquals(""+doc, 1, doc.size()); assertTrue(""+doc, doc.getFieldValue("log(val_i)") instanceof Double); for (SolrParams p : Arrays.asList(params("q","*:*", "rows", "1", "fl","log(val_i),abs(val_i)"), params("q","*:*", "rows", "1", "fl","log(val_i)", "fl","abs(val_i)"))) { docs = assertSearch(p); assertEquals(p + " => " + docs, 5, docs.getNumFound()); doc = docs.get(0); // doesn't really matter which one assertEquals(p + " => " + doc, 2, doc.size()); assertTrue(p + " => " + doc, doc.getFieldValue("log(val_i)") instanceof Double); assertTrue(p + " => " + doc, doc.getFieldValue("abs(val_i)") instanceof Float); } }
Example #2
Source File: MCROAISolrSearcher.java From mycore with GNU General Public License v3.0 | 6 votes |
protected MCROAISolrResult solrQuery(Optional<String> cursor) throws SolrServerException, IOException { SolrQuery query = getBaseQuery(CommonParams.Q); // set support if (this.set != null) { String setId = this.set.getSetId(); MCROAISetConfiguration<SolrQuery, SolrDocument, String> setConfig = getSetManager().getConfig(setId); setConfig.getHandler().apply(this.set, query); } // from & until if (this.from != null || this.until != null) { String fromUntilCondition = buildFromUntilCondition(this.from, this.until); query.add(CommonParams.FQ, fromUntilCondition); } // cursor query.set(CursorMarkParams.CURSOR_MARK_PARAM, cursor.orElse(CursorMarkParams.CURSOR_MARK_START)); query.set(CommonParams.ROWS, String.valueOf(getPartitionSize())); query.set(CommonParams.SORT, "id asc"); // do the query SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient(); QueryResponse response = solrClient.query(query); Collection<MCROAISetResolver<String, SolrDocument>> setResolver = getSetResolver(response.getResults()); return new MCROAISolrResult(response, d -> toHeader(d, setResolver)); }
Example #3
Source File: UnifiedSolrHighlighter.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Retrieves the unique keys for the topdocs to key the results */ protected String[] getUniqueKeys(SolrIndexSearcher searcher, int[] docIDs) throws IOException { IndexSchema schema = searcher.getSchema(); SchemaField keyField = schema.getUniqueKeyField(); if (keyField != null) { SolrReturnFields returnFields = new SolrReturnFields(keyField.getName(), null); String[] uniqueKeys = new String[docIDs.length]; for (int i = 0; i < docIDs.length; i++) { int docid = docIDs[i]; SolrDocument solrDoc = searcher.getDocFetcher().solrDoc(docid, returnFields); uniqueKeys[i] = schema.printableUniqueKey(solrDoc); } return uniqueKeys; } else { return new String[docIDs.length]; } }
Example #4
Source File: MergingSolrSpewer.java From extract with MIT License | 6 votes |
private void mergeField(final String name, final String newValue, final SolrDocument existingDocument, final SolrInputDocument inputDocument) { // Even though the superclass sets the path and parent path fields, we should set them again in case there's // a retry and they need to be overwritten. if (null == existingDocument) { setFieldValue(inputDocument, name, newValue); return; } // Create a HashSet from existing values so that only non-existing (distinct) values are added. // A HashSet gives constant time performance, as opposed to a loop, which is important when dealing with // potentially thousands of values. final Collection<Object> existingValues = existingDocument.getFieldValues(name); if (null != existingValues) { final Set<String> values = existingValues.stream() .map(String::valueOf) .collect(Collectors.toCollection(HashSet::new)); values.add(newValue); setFieldValue(inputDocument, name, values.toArray(new String[values.size()])); } else { setFieldValue(inputDocument, name, newValue); } }
Example #5
Source File: TestCloudPseudoReturnFields.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testGlobsAndScoreRTG() throws Exception { // behavior shouldn't matter if we are committed or uncommitted, score should be ignored for (String id : Arrays.asList("42","99")) { SolrDocument doc = getRandClient(random()).getById(id, params("fl","val_*,score")); String msg = id + ": fl=val_*,score => " + doc; assertEquals(msg, 1, doc.size()); assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer); assertEquals(msg, 1, doc.getFieldValue("val_i")); for (SolrParams p : Arrays.asList(params("fl","val_*,subj*,score"), params("fl","val_*","fl","subj*","fl","score"), params("fl","val_*","fl","subj*,score"))) { doc = getRandClient(random()).getById(id, p); msg = id + ": " + p + " => " + doc; assertEquals(msg, 2, doc.size()); assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer); assertEquals(msg, 1, doc.getFieldValue("val_i")); assertTrue(msg, doc.getFieldValue("subject") instanceof String); } } }
Example #6
Source File: TestCloudPseudoReturnFields.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testFunctionsAndScoreRTG() throws Exception { // if we use RTG (committed or otherwise) score should be ignored for (String id : Arrays.asList("42","99")) { for (SolrParams p : Arrays.asList(params("fl","score","fl","log(val_i)","fl","abs(val_i)"), params("fl","score","fl","log(val_i),abs(val_i)"), params("fl","score,log(val_i)","fl","abs(val_i)"), params("fl","score,log(val_i),abs(val_i)"))) { SolrDocument doc = getRandClient(random()).getById(id, p); String msg = id + "," + p + " => " + doc; assertEquals(msg, 2, doc.size()); assertTrue(msg, doc.getFieldValue("log(val_i)") instanceof Double); assertTrue(msg, doc.getFieldValue("abs(val_i)") instanceof Float); // true for both these specific docs assertEquals(msg, 0.0D, doc.getFieldValue("log(val_i)")); assertEquals(msg, 1.0F, doc.getFieldValue("abs(val_i)")); } } }
Example #7
Source File: TestCloudPseudoReturnFields.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testScoreAndExplicitRealFields() throws Exception { SolrDocumentList docs = null; SolrDocument doc = null; for (SolrParams p : Arrays.asList(params("q","*:*", "rows", "1", "fl","score,val_i"), params("q","*:*", "rows", "1", "fl","score", "fl","val_i"))) { docs = assertSearch(p); assertEquals(p + " => " + docs, 5, docs.getNumFound()); doc = docs.get(0); // doesn't really matter which one assertEquals(p + " => " + doc, 2, doc.size()); assertTrue(p + " => " + doc, doc.getFieldValue("val_i") instanceof Integer); assertTrue(p + " => " + doc, doc.getFieldValue("score") instanceof Float); } docs = assertSearch(params("q","*:*", "rows", "1", "fl","val_i")); assertEquals("" + docs, 5, docs.getNumFound()); doc = docs.get(0); // doesn't really matter which one assertEquals("" + doc, 1, doc.size()); assertTrue("" + doc, doc.getFieldValue("val_i") instanceof Integer); }
Example #8
Source File: MCRSolrSearchUtils.java From mycore with GNU General Public License v3.0 | 6 votes |
@Override public boolean tryAdvance(Consumer<? super SolrDocument> action) { if (action == null) { throw new NullPointerException(); } long i = start, size = estimateSize(); if (size > 0) { if (response == null) { ModifiableSolrParams p = new ModifiableSolrParams(params); p.set("start", (int) i); p.set("rows", (int) rows); response = query(p); } action.accept(response.getResults().get(response.getResults().size() - (int) size)); this.start = i + 1; this.size -= 1; return true; } return false; }
Example #9
Source File: SolrTest.java From parker with MIT License | 6 votes |
@Test public void testQuery() throws Exception { SolrQuery query = new SolrQuery(); // 根据标题或内容来搜索 query.setQuery("title:项目 or content:项目"); // 返回的字段 query.addField("id"); query.addField("title"); query.addField("content"); QueryResponse response = client.query(query); SolrDocumentList documents = response.getResults(); System.out.println("结果集大小=" + documents.size()); for(SolrDocument document : documents) { final String title = (String) document.getFirstValue("title"); System.out.println(title); //final String name = (String) document.getFirstValue("name"); //System.out.println("id: " + id + "; name: " + name); } }
Example #10
Source File: SolrJavaLiveTest.java From tutorials with MIT License | 6 votes |
@Test public void whenAdd_thenVerifyAddedByQueryOnPrice() throws SolrServerException, IOException { SolrQuery query = new SolrQuery(); query.set("q", "price:599.99"); QueryResponse response = null; response = solrJavaIntegration.getSolrClient().query(query); SolrDocumentList docList = response.getResults(); assertEquals(1, docList.getNumFound()); for (SolrDocument doc : docList) { assertEquals("123456", (String) doc.getFieldValue("id")); assertEquals((Double) 599.99, (Double) doc.getFieldValue("price")); } }
Example #11
Source File: SolrLookingBlurServerTest.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
@Test public void fieldsRequestsShouldTurnIntoSelectors() throws Exception, TException { String table = "fieldsRequestsShouldTurnIntoSelectors"; SolrServer server = TestTableCreator.newTable(table) .withRowCount(1).withRecordsPerRow(2) .withRecordColumns("fam.value", "fam.mvf").create(); SolrQuery query = new SolrQuery("value0-0"); query.setFields("fam.value"); QueryResponse response = server.query(query); assertEquals("We should get our doc back for a valid test.", 1l, response.getResults().getNumFound()); SolrDocument docResult = response.getResults().get(0); assertEquals("value0-0", docResult.getFieldValue("fam.value")); assertNull("We shouldn't get this one back since it wasnt in our fields.", docResult.getFieldValues("fam.mvf")); removeTable(table); }
Example #12
Source File: GetByIdTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testGetIdWithParams() throws Exception { final SolrParams ID_FL_ONLY = params(CommonParams.FL, "id"); SolrDocument rsp = getSolrClient().getById("0", ID_FL_ONLY); assertNull(rsp); rsp = getSolrClient().getById("1", ID_FL_ONLY); assertEquals("1", rsp.get("id")); assertNull("This field should have been removed from the response.", rsp.get("term_s")); assertNull("This field should have been removed from the response.", rsp.get("term2_s")); rsp = getSolrClient().getById("2", ID_FL_ONLY); assertEquals("2", rsp.get("id")); assertNull("This field should have been removed from the response.", rsp.get("term_s")); assertNull("This field should have been removed from the response.", rsp.get("term2_s")); }
Example #13
Source File: SolrUtils.java From vind with Apache License 2.0 | 6 votes |
public static SolrInputDocument toSolrInputDocument(SolrDocument solrDocument) { SolrInputDocument solrInputDocument = new SolrInputDocument(); for (String name : solrDocument.getFieldNames()) { solrInputDocument.addField(name, solrDocument.getFieldValue(name)); } //Don't forget children documents if(solrDocument.getChildDocuments() != null) { for(SolrDocument childDocument : solrDocument.getChildDocuments()) { //You can add paranoic check against infinite loop childDocument == solrDocument solrInputDocument.addChildDocument(toSolrInputDocument(childDocument)); } } return solrInputDocument; }
Example #14
Source File: TestCloudPseudoReturnFields.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testFunctionsAndExplicitRTG() throws Exception { // shouldn't matter if we use RTG (committed or otherwise) for (String id : Arrays.asList("42","99")) { for (SolrParams p : Arrays.asList(params("fl","log(val_i),val_i"), params("fl","log(val_i)","fl","val_i"))) { SolrDocument doc = getRandClient(random()).getById(id, p); String msg = id + "," + p + " => " + doc; assertEquals(msg, 2, doc.size()); assertTrue(msg, doc.getFieldValue("log(val_i)") instanceof Double); assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer); // true for both these specific docs assertEquals(msg, 0.0D, doc.getFieldValue("log(val_i)")); assertEquals(msg, 1, doc.getFieldValue("val_i")); } } }
Example #15
Source File: TestMerge.java From BioSolr with Apache License 2.0 | 6 votes |
/** * When [shard] is not in the field list, the [shard] field should not be returned, even * if score is in the field list. */ @Test public void testNotWantsShardWithScore() throws Exception { try (SolrCore core = h.getCoreContainer().getCore("merge")) { ModifiableSolrParams params = new ModifiableSolrParams(); params.add("q", "*:*"); params.add("sort", "letter asc"); params.add("fl", "*,score"); SolrDocumentList docs = queryDocs(core, "merge", params); assertEquals(3, docs.size()); for (SolrDocument doc : docs) { assertNull(doc.getFieldValue("[shard]")); assertEquals(1.0f, doc.getFieldValue("score")); } } }
Example #16
Source File: TestCloudPseudoReturnFields.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testAugmentersAndExplicit() throws Exception { for (SolrParams p : Arrays.asList(params("q", "*:*", "fl","id,[docid],[explain],x_alias:[value v=10 t=int]"), params("q", "*:*", "fl","id","fl","[docid],[explain],x_alias:[value v=10 t=int]"), params("q", "*:*", "fl","id","fl","[docid]","fl","[explain]","fl","x_alias:[value v=10 t=int]"))) { SolrDocumentList docs = assertSearch(p); assertEquals(p + " => " + docs, 5, docs.getNumFound()); // shouldn't matter what doc we pick... for (SolrDocument doc : docs) { String msg = p + " => " + doc; assertEquals(msg, 4, doc.size()); assertTrue(msg, doc.getFieldValue("id") instanceof String); assertTrue(msg, doc.getFieldValue("[docid]") instanceof Integer); assertTrue(msg, doc.getFieldValue("[explain]") instanceof String); assertTrue(msg, doc.getFieldValue("x_alias") instanceof Integer); assertEquals(msg, 10, doc.getFieldValue("x_alias")); } } }
Example #17
Source File: UpdateLogTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testApplyPartialUpdatesAfterMultipleCommits() { ulogAdd(ulog, null, sdoc("id", "1", "title_s", "title1", "val1_i_dvo", "1", "_version_", "100")); ulogAdd(ulog, 100L, sdoc("id", "1", "price", "1000", "val1_i_dvo", "2", "_version_", "101")); ulogAdd(ulog, 101L, sdoc("id", "1", "val1_i_dvo", "3", "_version_", "102")); // Do 3 commits, then in-place update, and verify that applying partial updates can't find full doc for (int i=0; i<3; i++) ulogCommit(ulog); ulogAdd(ulog, 101L, sdoc("id", "1", "val1_i_dvo", "6", "_version_", "300")); Object partialUpdate = ulog.lookup(DOC_1_INDEXED_ID); SolrDocument partialDoc = RealTimeGetComponent.toSolrDoc((SolrInputDocument)((List)partialUpdate).get(4), h.getCore().getLatestSchema()); long prevVersion = (Long)((List)partialUpdate).get(3); long prevPointer = (Long)((List)partialUpdate).get(2); assertEquals(6L, ((NumericDocValuesField)partialDoc.getFieldValue("val1_i_dvo")).numericValue()); assertFalse(partialDoc.containsKey("title_s")); long returnVal = ulog.applyPartialUpdates(DOC_1_INDEXED_ID, prevPointer, prevVersion, null, partialDoc); assertEquals(-1, returnVal); }
Example #18
Source File: DeepPagingIterator.java From SolRDF with Apache License 2.0 | 6 votes |
@Override public Triple next() { final SolrDocument document = iterator().next(); Triple triple = null; if (consumer.requireTripleBuild()) { triple = Triple.create( NTriples.asURIorBlankNode((String) document.getFieldValue(Field.S)), NTriples.asURI((String) document.getFieldValue(Field.P)), NTriples.asNode((String) document.getFieldValue(Field.O))); } else { triple = DUMMY_TRIPLE; } // FIXME // consumer.afterTripleHasBeenBuilt(triple, nextDocId); return triple; }
Example #19
Source File: TestRandomFlRTGCloud.java From lucene-solr with Apache License 2.0 | 6 votes |
public Collection<String> assertRTGResults(final Collection<FlValidator> validators, final SolrInputDocument expected, final SolrDocument actual) { final int compVal = assertParseInt("expected id", expected.getFieldValue("id")); final Object actualVal = actual.getFieldValue(SUBQ_KEY); assertTrue("Expected a doclist: " + actualVal, actualVal instanceof SolrDocumentList); assertTrue("should be at most 2 docs in doc list: " + actualVal, ((SolrDocumentList) actualVal).getNumFound() <= 2); for (SolrDocument subDoc : (SolrDocumentList) actualVal) { final int subDocIdVal = assertParseInt("subquery id", subDoc.getFirstValue("id")); assertTrue("subDocId="+subDocIdVal+" not in valid range for id="+compVal+" (expected " + (compVal-1) + " or " + (compVal-2) + ")", ((subDocIdVal < compVal) && ((compVal-2) <= subDocIdVal))); } return Collections.<String>singleton(SUBQ_KEY); }
Example #20
Source File: SmileWriterTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public static SolrDocument sampleDoc(Random r, int bufnum) { SolrDocument sdoc = new SolrDocument(); sdoc.put("id", "my_id_" + bufnum); sdoc.put("author", str(r, 10 + r.nextInt(10))); sdoc.put("address", str(r, 20 + r.nextInt(20))); sdoc.put("license", str(r, 10)); sdoc.put("title", str(r, 5 + r.nextInt(10))); sdoc.put("title_bin", str(r, 5 + r.nextInt(10)).getBytes(StandardCharsets.UTF_8)); sdoc.put("modified_dt", r.nextInt(1000000)); sdoc.put("creation_dt", r.nextInt(1000000)); sdoc.put("birthdate_dt", r.nextInt(1000000)); sdoc.put("clean", r.nextBoolean()); sdoc.put("dirty", r.nextBoolean()); sdoc.put("employed", r.nextBoolean()); sdoc.put("priority", r.nextInt(100)); sdoc.put("dependents", r.nextInt(6)); sdoc.put("level", r.nextInt(101)); sdoc.put("education_level", r.nextInt(10)); // higher level of reuse for string values sdoc.put("state", "S"+r.nextInt(50)); sdoc.put("country", "Country"+r.nextInt(20)); sdoc.put("some_boolean", ""+r.nextBoolean()); sdoc.put("another_boolean", ""+r.nextBoolean()); return sdoc; }
Example #21
Source File: DocumentShrinker.java From thoth with BSD 3-Clause Clear License | 6 votes |
/** * Tag slower documents and add them to the shrank core */ private void tagAndAddSlowThothDocuments() throws IOException, SolrServerException { // Query to return top MAX_NUMBER_SLOW_THOTH_DOCS slower thoth documents QueryResponse qr = realTimeServer.query( new SolrQuery() .setQuery(createThothDocsAggregationQuery()) .addSort(QTIME, SolrQuery.ORDER.desc) .setRows(MAX_NUMBER_SLOW_THOTH_DOCS) ); for (SolrDocument solrDocument: qr.getResults()){ SolrInputDocument si = ClientUtils.toSolrInputDocument(solrDocument); // Remove old ID and version si.removeField(ID); si.removeField("_version_"); // Tag document as slow si.addField(SLOW_QUERY_DOCUMENT, true); LOG.debug("Adding slow query document for server " + serverDetail.getName()); shrankServer.add(si); } }
Example #22
Source File: BaseEditorialTransformer.java From lucene-solr with Apache License 2.0 | 6 votes |
protected BytesRef getKey(SolrDocument doc) { Object obj = doc.get(idFieldName); if (obj instanceof IndexableField) { IndexableField f = (IndexableField) obj; BytesRefBuilder bytesRefBuilder = new BytesRefBuilder(); Number n = f.numericValue(); if (n != null) { ft.readableToIndexed(n.toString(), bytesRefBuilder); } else { ft.readableToIndexed(f.stringValue(), bytesRefBuilder); } return bytesRefBuilder.get(); } else if (obj instanceof String) { // Allows the idField to be stored=false, docValues=true return new BytesRef(((String)obj)); } throw new AssertionError("Expected an IndexableField but got: " + obj.getClass()); }
Example #23
Source File: UpdateLogTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testApplyPartialUpdatesDependingOnNonAddShouldThrowException() { ulogAdd(ulog, null, sdoc("id", "1", "title_s", "title1", "val1_i_dvo", "1", "_version_", "100")); ulogDelete(ulog, "1", 500L, false); // dbi ulogAdd(ulog, 500L, sdoc("id", "1", "val1_i_dvo", "2", "_version_", "501")); ulogAdd(ulog, 501L, sdoc("id", "1", "val1_i_dvo", "3", "_version_", "502")); Object partialUpdate = ulog.lookup(DOC_1_INDEXED_ID); SolrDocument partialDoc = RealTimeGetComponent.toSolrDoc((SolrInputDocument)((List)partialUpdate).get(4), h.getCore().getLatestSchema()); long prevVersion = (Long)((List)partialUpdate).get(3); long prevPointer = (Long)((List)partialUpdate).get(2); assertEquals(3L, ((NumericDocValuesField)partialDoc.getFieldValue("val1_i_dvo")).numericValue()); assertEquals(502L, ((NumericDocValuesField)partialDoc.getFieldValue("_version_")).numericValue()); assertFalse(partialDoc.containsKey("title_s")); // If an in-place update depends on a non-add (i.e. DBI), assert that an exception is thrown. SolrException ex = expectThrows(SolrException.class, () -> { long returnVal = ulog.applyPartialUpdates(DOC_1_INDEXED_ID, prevPointer, prevVersion, null, partialDoc); fail("502 depends on 501, 501 depends on 500, but 500 is a" + " DELETE. This should've generated an exception. returnVal is: "+returnVal); }); assertEquals(ex.toString(), SolrException.ErrorCode.INVALID_STATE.code, ex.code()); assertThat(ex.getMessage(), containsString("should've been either ADD or UPDATE_INPLACE")); assertThat(ex.getMessage(), containsString("looking for id=1")); }
Example #24
Source File: LuceneIndexHandler.java From FXDesktopSearch with Apache License 2.0 | 6 votes |
private String getOrDefault(SolrDocument document, String aFieldname, String aDefault) { Object theValue = document.get(aFieldname); if (theValue == null) { return aDefault; } if (theValue instanceof String) { return (String) theValue; } if (theValue instanceof List) { List theList = (List) theValue; if (theList.isEmpty()) { return aDefault; } Object theFirst = theList.get(0); if (theFirst instanceof String) { return (String) theFirst; } return aDefault; } return aDefault; }
Example #25
Source File: EmbeddedSolrNoSerializeTest.java From SolrTextTagger with Apache License 2.0 | 6 votes |
public void doTestAssertTagStreaming(BiFunction<ModifiableSolrParams,String,QueryRequest> newQueryRequest) throws IOException, SolrServerException { ModifiableSolrParams params = params(); String input = "foo boston bar";//just one tag; QueryRequest req = newQueryRequest.apply(params, input); req.setPath("/tag"); final AtomicReference<SolrDocument> refDoc = new AtomicReference<>(); req.setStreamingResponseCallback(new StreamingResponseCallback() { @Override public void streamSolrDocument(SolrDocument doc) { refDoc.set(doc); } @Override public void streamDocListInfo(long numFound, long start, Float maxScore) { } }); QueryResponse rsp = req.process(solrServer); assertNotNull(rsp.getResponse().get("tags")); assertNotNull(refDoc.get()); assertEquals("Boston", ((Field)refDoc.get().getFieldValue("name")).stringValue()); }
Example #26
Source File: AbstractSolrSentryTestBase.java From incubator-sentry with Apache License 2.0 | 5 votes |
/** * Function to validate the count and content of two SolrDocumentList's. * @param solrOriginalDocs - Instance of initial set of solr docs before processing * @param solrResponseDocs - Instance of response solr docs after processing */ protected void validateSolrDocCountAndContent(SolrDocumentList solrOriginalDocs, SolrDocumentList solrResponseDocs) { assertEquals("Expected number of Solr docs: " + solrOriginalDocs.size() + "; But found:" + solrResponseDocs.size(), solrOriginalDocs.size(), solrResponseDocs.size()); for (SolrDocument solrDoc : solrOriginalDocs) { SolrInputDocument solrInputDoc = ClientUtils.toSolrInputDocument(solrDoc); validateSolrDocContent(solrInputDoc, solrResponseDocs); } }
Example #27
Source File: JavaBinCodecCoderTest.java From beam with Apache License 2.0 | 5 votes |
@Test public void testDecodeEncodeEqual() throws Exception { for (SolrDocument value : TEST_VALUES) { CoderProperties.coderDecodeEncodeContentsInSameOrder(TEST_CODER, value); CoderProperties.structuralValueDecodeEncodeEqual(TEST_CODER, value); } }
Example #28
Source File: SolrStreamingService.java From chronix.spark with Apache License 2.0 | 5 votes |
private void convertStream() { SolrDocument document; do { document = solrStreamingHandler.pool(); if (document != null) { ListenableFuture future = service.submit(new TimeSeriesConverterCaller<>(document, converter, queryStart, queryEnd)); Futures.addCallback(future, timeSeriesHandler); } } while (solrStreamingHandler.canPoll()); }
Example #29
Source File: RenameFieldTransformer.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void transform(SolrDocument doc, int docid) { Object v = (copy)?doc.get(from) : doc.remove( from ); if( v != null ) { doc.setField(to, v); } }
Example #30
Source File: SolrIOTest.java From beam with Apache License 2.0 | 5 votes |
@Test public void testRead() throws Exception { SolrIOTestUtils.insertTestDocuments(SOLR_COLLECTION, NUM_DOCS, solrClient); PCollection<SolrDocument> output = pipeline.apply( SolrIO.read() .withConnectionConfiguration(connectionConfiguration) .from(SOLR_COLLECTION) .withBatchSize(101)); PAssert.thatSingleton(output.apply("Count", Count.globally())).isEqualTo(NUM_DOCS); pipeline.run(); }