Java Code Examples for org.apache.solr.handler.UpdateRequestHandler#init()

The following examples show how to use org.apache.solr.handler.UpdateRequestHandler#init() . 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: SolrTestCaseJ4.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public static void addDoc(String doc, String updateRequestProcessorChain) throws Exception {
  Map<String, String[]> params = new HashMap<>();
  MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
  params.put(UpdateParams.UPDATE_CHAIN, new String[]{updateRequestProcessorChain});
  SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(),
      (SolrParams) mmparams) {
  };

  UpdateRequestHandler handler = new UpdateRequestHandler();
  handler.init(null);
  ArrayList<ContentStream> streams = new ArrayList<>(2);
  streams.add(new ContentStreamBase.StringStream(doc));
  req.setContentStreams(streams);
  handler.handleRequestBody(req, new SolrQueryResponse());
  req.close();
}
 
Example 2
Source File: UniqFieldsUpdateProcessorFactoryTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void addDoc(String doc) throws Exception {
  Map<String, String[]> params = new HashMap<>();
  MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
  params.put(UpdateParams.UPDATE_CHAIN, new String[] { "uniq-fields" });
  SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(),
      (SolrParams) mmparams) {
  };

  UpdateRequestHandler handler = new UpdateRequestHandler();
  handler.init(null);
  ArrayList<ContentStream> streams = new ArrayList<>(2);
  streams.add(new ContentStreamBase.StringStream(doc));
  req.setContentStreams(streams);
  handler.handleRequestBody(req, new SolrQueryResponse());
  req.close();
}
 
Example 3
Source File: TestHarness.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Create a TestHarness using a specific config
 * @param config the ConfigSolr to use
 */
public TestHarness(NodeConfig config, CoresLocator coresLocator) {
  container = new CoreContainer(config, coresLocator);
  container.load();
  updater = new UpdateRequestHandler();
  updater.init(null);
}
 
Example 4
Source File: MaxSizeAutoCommitTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
  System.setProperty("solr.ulog", "solr.UpdateLog");
  initCore("solrconfig-tlog.xml", "schema.xml");
  core = h.getCore();
  updateHandler = (DirectUpdateHandler2) core.getUpdateHandler();

  // we don't care about auto-commit's opening a new Searcher in this test, just skip it.
  updateHandler.softCommitTracker.setOpenSearcher(false);
  updateHandler.commitTracker.setOpenSearcher(false);

  // we don't care about soft commit's at all
  updateHandler.softCommitTracker.setTimeUpperBound(-1);
  updateHandler.softCommitTracker.setDocsUpperBound(-1);
  updateHandler.softCommitTracker.setTLogFileSizeUpperBound(-1);
  
  hardCommitTracker = updateHandler.commitTracker;
  // Only testing file-size based auto hard commits - disable other checks
  hardCommitTracker.setTimeUpperBound(-1);
  hardCommitTracker.setDocsUpperBound(-1);
  hardCommitTracker.setTLogFileSizeUpperBound(MAX_FILE_SIZE);

  monitor = new MockEventListener();
  updateHandler.registerCommitCallback(monitor);
  
  updateRequestHandler = new UpdateRequestHandler();
  updateRequestHandler.init( null );
}
 
Example 5
Source File: OntologyUpdateProcessorFactoryTest.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
static void addDoc(String doc, String chain) throws Exception {
	Map<String, String[]> params = new HashMap<>();
	MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
	params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
	SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), mmparams) {
	};

	UpdateRequestHandler handler = new UpdateRequestHandler();
	handler.init(null);
	ArrayList<ContentStream> streams = new ArrayList<>(2);
	streams.add(new ContentStreamBase.StringStream(doc));
	req.setContentStreams(streams);
	handler.handleRequestBody(req, new SolrQueryResponse());
	req.close();
}