List of usage examples for org.apache.solr.core SolrCore getUpdateProcessingChain
public UpdateRequestProcessorChain getUpdateProcessingChain(final String name)
From source file:com.sindicetech.siren.solr.UpdateProcessorTestBase.java
License:Open Source License
/** * Runs a document through the specified chain, and returns the final * document used when the chain is completed (NOTE: some chains may * modify the document in place/* ww w . j a v a 2 s .c o m*/ */ protected SolrInputDocument processAdd(final String chain, final SolrParams requestParams, final SolrInputDocument docIn) throws IOException { SolrCore core = h.getCore(); UpdateRequestProcessorChain pc = core.getUpdateProcessingChain(chain); assertNotNull("No Chain named: " + chain, pc); SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequest req = new LocalSolrQueryRequest(core, requestParams); try { AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = docIn; UpdateRequestProcessor processor = pc.createProcessor(req, rsp); processor.processAdd(cmd); return cmd.solrDoc; } finally { req.close(); } }
From source file:io.yucca.solr.processor.HierarchyExtractorUpdateProcessorTestCase.java
License:Apache License
@BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-hierextractor.xml", "schema.xml", getFile("src/test/resources/test-files/hierextr/solr").getAbsolutePath()); SolrCore core = h.getCore(); UpdateRequestProcessorChain chained = core.getUpdateProcessingChain("hier_extr"); assertNotNull(chained);/*from w w w .ja va 2 s . c om*/ _parser = new SolrRequestParsers(null); }
From source file:io.yucca.solr.processor.RegexExtractorUpdateProcessorTestCase.java
License:Apache License
@BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-regexextractor.xml", "schema.xml", getFile("src/test/resources/test-files/regexextr/solr").getAbsolutePath()); SolrCore core = h.getCore(); UpdateRequestProcessorChain chained = core.getUpdateProcessingChain("regex_extr"); assertNotNull(chained);/*from w ww . j a va 2 s.c o m*/ _parser = new SolrRequestParsers(null); }
From source file:org.alfresco.solr.component.QueryLoggingComponent.java
License:Open Source License
private void log(ResponseBuilder rb) throws IOException { boolean isShard = rb.req.getParams().getBool(ShardParams.IS_SHARD, false); if (!isShard) { CoreContainer container = rb.req.getCore().getCoreContainer(); SolrCore logCore = container.getCore(rb.req.getCore().getName() + "_qlog"); if (logCore != null) { JSONObject json = (JSONObject) rb.req.getContext().get(AbstractQParser.ALFRESCO_JSON); SolrQueryRequest request = null; UpdateRequestProcessor processor = null; try { request = new LocalSolrQueryRequest(logCore, new NamedList<>()); processor = logCore.getUpdateProcessingChain(null).createProcessor(request, new SolrQueryResponse()); AddUpdateCommand cmd = new AddUpdateCommand(request); cmd.overwrite = true;// w w w . ja v a 2s . c om SolrInputDocument input = new SolrInputDocument(); input.addField("id", GUID.generate()); input.addField("_version_", "1"); input.addField("timestamp", DateTimeFormatter.ISO_INSTANT.format(Instant.now())); if (json != null) { try { ArrayList<String> authorityList = new ArrayList<String>(1); JSONArray authorities = json.getJSONArray("authorities"); for (int i = 0; i < authorities.length(); i++) { String authorityString = authorities.getString(i); authorityList.add(authorityString); } for (String authority : authorityList) { if (AuthorityType.getAuthorityType(authority) == AuthorityType.USER) { input.addField("user", authority); break; } } } catch (JSONException e) { input.addField("user", "<UNKNOWN>"); } } else { input.addField("user", "<UNKNOWN>"); } String userQuery = rb.req.getParams().get(SpellingParams.SPELLCHECK_Q); if (userQuery == null) { if (json != null) { try { userQuery = json.getString("query"); } catch (JSONException e) { } } } if (userQuery == null) { userQuery = rb.req.getParams().get(CommonParams.Q); } if (userQuery != null) { input.addField("user_query", userQuery); } Query query = rb.getQuery(); input.addField("query", query.toString()); if (rb.getResults().docList != null) { input.addField("found", rb.getResults().docList.matches()); } input.addField("time", rb.req.getRequestTimer().getTime()); cmd.solrDoc = input; processor.processAdd(cmd); } finally { if (processor != null) { processor.finish(); } if (request != null) { request.close(); } } } } }