Java Code Examples for org.apache.solr.core.SolrCore#getRequestHandler()
The following examples show how to use
org.apache.solr.core.SolrCore#getRequestHandler() .
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: SimpleTreeFacetComponentTest.java From BioSolr with Apache License 2.0 | 6 votes |
@Test public void testBadRequest_missingChildField() { SolrCore core = h.getCore(); ModifiableSolrParams params = new ModifiableSolrParams(); params.add("q", "*:*"); params.add("facet", "true"); params.add("facet.tree", "true"); params.add("facet.tree.field", "{!ftree childField=blah}node_id"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler(requestHandler); handler.handleRequest(req, rsp); req.close(); assertNotNull(rsp.getException()); }
Example 2
Source File: SimpleTreeFacetComponentTest.java From BioSolr with Apache License 2.0 | 6 votes |
@Test public void testBadRequest_missingLocalParams() { SolrCore core = h.getCore(); ModifiableSolrParams params = new ModifiableSolrParams(); params.add("q", "*:*"); params.add("facet", "true"); params.add("facet.tree", "true"); params.add("facet.tree.field", "node_id"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler(requestHandler); handler.handleRequest(req, rsp); req.close(); assertNotNull(rsp.getException()); }
Example 3
Source File: AbstractXJoinTestCase.java From BioSolr with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") protected NamedList test(ModifiableSolrParams params, String componentName) { SolrCore core = h.getCore(); SearchComponent sc = core.getSearchComponent(componentName); assertTrue("XJoinSearchComponent not found in solrconfig", sc != null); QParserPlugin qp = core.getQueryPlugin("xjoin"); assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null); params.add("q", "*:*"); params.add("fq", "{!xjoin}" + componentName); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler("standard"); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); return rsp.getValues(); }
Example 4
Source File: AbstractXJoinTestCase.java From BioSolr with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") protected NamedList test(ModifiableSolrParams params, String componentName) { SolrCore core = h.getCore(); SearchComponent sc = core.getSearchComponent(componentName); assertTrue("XJoinSearchComponent not found in solrconfig", sc != null); QParserPlugin qp = core.getQueryPlugin("xjoin"); assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null); params.add("q", "*:*"); params.add("fq", "{!xjoin}" + componentName); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler("standard"); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); return rsp.getValues(); }
Example 5
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
public SolrInformationServer(AlfrescoCoreAdminHandler adminHandler, SolrCore core, SOLRAPIClient repositoryClient) { this.adminHandler = adminHandler; this.core = core; this.nativeRequestHandler = core.getRequestHandler(REQUEST_HANDLER_NATIVE); this.cloud = new Cloud(); this.repositoryClient = Objects.requireNonNull(repositoryClient); Properties coreConfiguration = core.getResourceLoader().getCoreProperties(); contentIndexingHasBeenEnabledOnThisInstance = Boolean.parseBoolean(coreConfiguration.getProperty("alfresco.index.transformContent", "true")); LOGGER.info( "Content Indexing (AKA Transformation) has been {} on this instance.", contentIndexingHasBeenEnabledOnThisInstance ? "enabled" : "disabled"); recordUnindexedNodes = Boolean.parseBoolean(coreConfiguration.getProperty("alfresco.recordUnindexedNodes", "true")); lag = Integer.parseInt(coreConfiguration.getProperty("alfresco.lag", "1000")); holeRetention = Integer.parseInt(coreConfiguration.getProperty("alfresco.hole.retention", "3600000")); fingerprintHasBeenEnabledOnThisInstance = Boolean.parseBoolean(coreConfiguration.getProperty("alfresco.fingerprint", "true")); LOGGER.info( "Fingerprint has been {} on this instance.", fingerprintHasBeenEnabledOnThisInstance ? "enabled" : "disabled"); dataModel = AlfrescoSolrDataModel.getInstance(); contentStreamLimit = Integer.parseInt(coreConfiguration.getProperty("alfresco.contentStreamLimit", "10000000")); props = AlfrescoSolrDataModel.getCommonConfig(); hostName = ConfigUtil.locateProperty(SOLR_HOST, props.getProperty(SOLR_HOST)); port = portNumber(props); baseUrl = baseUrl(props); dateFieldDestructuringHasBeenEnabledOnThisInstance = Boolean.parseBoolean(coreConfiguration.getProperty("alfresco.destructureDateFields", "true")); LOGGER.info( "Date fields destructuring has been {} on this instance.", dateFieldDestructuringHasBeenEnabledOnThisInstance ? "enabled" : "disabled"); }
Example 6
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testCollationWithRangeQuery() throws Exception { SolrCore core = h.getCore(); SearchComponent speller = core.getSearchComponent("spellcheck"); assertTrue("speller is null and it shouldn't be", speller != null); ModifiableSolrParams params = new ModifiableSolrParams(); params.add(SpellCheckComponent.COMPONENT_NAME, "true"); params.add(SpellingParams.SPELLCHECK_BUILD, "true"); params.add(SpellingParams.SPELLCHECK_COUNT, "10"); params.add(SpellingParams.SPELLCHECK_COLLATE, "true"); params.add(SpellingParams.SPELLCHECK_ALTERNATIVE_TERM_COUNT, "10"); params.add(CommonParams.Q, "id:[1 TO 10] AND lowerfilt:lovw"); { SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.addResponseHeader(new SimpleOrderedMap()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); req.close(); NamedList values = rsp.getValues(); NamedList spellCheck = (NamedList) values.get("spellcheck"); NamedList collationHolder = (NamedList) spellCheck.get("collations"); List<String> collations = collationHolder.getAll("collation"); assertTrue(collations.size()==1); String collation = collations.iterator().next(); System.out.println(collation); assertTrue("Incorrect collation: " + collation,"id:[1 TO 10] AND lowerfilt:love".equals(collation)); } }
Example 7
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testCollateWithFilter() throws Exception { SolrCore core = h.getCore(); SearchComponent speller = core.getSearchComponent("spellcheck"); assertTrue("speller is null and it shouldn't be", speller != null); ModifiableSolrParams params = new ModifiableSolrParams(); params.add(SpellCheckComponent.COMPONENT_NAME, "true"); params.add(SpellingParams.SPELLCHECK_BUILD, "true"); params.add(SpellingParams.SPELLCHECK_COUNT, "10"); params.add(SpellingParams.SPELLCHECK_COLLATE, "true"); params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10"); params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10"); params.add(CommonParams.Q, "lowerfilt:(+fauth +home +loane)"); params.add(CommonParams.FQ, "NOT(id:1)"); //Because a FilterQuery is applied which removes doc id#1 from possible hits, we would //not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1. SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.addResponseHeader(new SimpleOrderedMap()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); req.close(); NamedList values = rsp.getValues(); NamedList spellCheck = (NamedList) values.get("spellcheck"); NamedList collationHolder = (NamedList) spellCheck.get("collations"); List<String> collations = collationHolder.getAll("collation"); assertTrue(collations.size() > 0); for(String collation : collations) { assertTrue(!collation.equals("lowerfilt:(+faith +hope +loaves)")); } }
Example 8
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testCollateWithGrouping() throws Exception { SolrCore core = h.getCore(); SearchComponent speller = core.getSearchComponent("spellcheck"); assertTrue("speller is null and it shouldn't be", speller != null); ModifiableSolrParams params = new ModifiableSolrParams(); params.add(SpellCheckComponent.COMPONENT_NAME, "true"); params.add(SpellingParams.SPELLCHECK_BUILD, "true"); params.add(SpellingParams.SPELLCHECK_COUNT, "10"); params.add(SpellingParams.SPELLCHECK_COLLATE, "true"); params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "5"); params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1"); params.add(CommonParams.Q, "lowerfilt:(+fauth)"); params.add(GroupParams.GROUP, "true"); params.add(GroupParams.GROUP_FIELD, "id"); //Because a FilterQuery is applied which removes doc id#1 from possible hits, we would //not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1. SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.addResponseHeader(new SimpleOrderedMap()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); req.close(); NamedList values = rsp.getValues(); NamedList spellCheck = (NamedList) values.get("spellcheck"); NamedList collationHolder = (NamedList) spellCheck.get("collations"); List<String> collations = collationHolder.getAll("collation"); assertTrue(collations.size() == 1); }
Example 9
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testZeroTries() throws Exception { SolrCore core = h.getCore(); SearchComponent speller = core.getSearchComponent("spellcheck"); assertTrue("speller is null and it shouldn't be", speller != null); ModifiableSolrParams params = new ModifiableSolrParams(); params.add(SpellCheckComponent.COMPONENT_NAME, "true"); params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true"); params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10"); params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true"); params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "0"); params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "2"); params.add(CommonParams.Q, "lowerfilt:(+fauth)"); SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.addResponseHeader(new SimpleOrderedMap()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); req.close(); NamedList values = rsp.getValues(); NamedList spellCheck = (NamedList) values.get("spellcheck"); NamedList collationList = (NamedList) spellCheck.get("collations"); List<?> collations = (List<?>) collationList.getAll("collation"); assertTrue(collations.size() == 2); }
Example 10
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testWithCursorMark() throws Exception { SolrCore core = h.getCore(); SearchComponent speller = core.getSearchComponent("spellcheck"); assertTrue("speller is null and it shouldn't be", speller != null); ModifiableSolrParams params = new ModifiableSolrParams(); params.add(SpellCheckComponent.COMPONENT_NAME, "true"); params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true"); params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10"); params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true"); params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "2"); params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1"); params.add(CommonParams.Q, "lowerfilt:(+fauth)"); params.add(CommonParams.SORT, "id asc"); params.add(CursorMarkParams.CURSOR_MARK_PARAM, CursorMarkParams.CURSOR_MARK_START); SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.addResponseHeader(new SimpleOrderedMap()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); req.close(); NamedList values = rsp.getValues(); NamedList spellCheck = (NamedList) values.get("spellcheck"); NamedList collationList = (NamedList) spellCheck.get("collations"); List<?> collations = (List<?>) collationList.getAll("collation"); assertTrue(collations.size() == 1); }
Example 11
Source File: QuerySegmenterComponentTest.java From query-segmenter with Apache License 2.0 | 5 votes |
private SolrQueryRequest request(ModifiableSolrParams params, String handlerName) { SolrCore core = h.getCore(); SolrRequestHandler handler = core.getRequestHandler(handlerName); SolrQueryResponse rsp = new SolrQueryResponse(); NamedList<Object> list = new NamedList<Object>(); list.add("responseHeader", new SimpleOrderedMap<Object>()); rsp.setAllValues(list); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); return req; }
Example 12
Source File: QuerySegmenterQParserTest.java From query-segmenter with Apache License 2.0 | 5 votes |
private SolrQueryRequest request(ModifiableSolrParams params, String handlerName) { SolrCore core = h.getCore(); SolrRequestHandler handler = core.getRequestHandler(handlerName); SolrQueryResponse rsp = new SolrQueryResponse(); NamedList<Object> list = new NamedList<Object>(); list.add("responseHeader", new SimpleOrderedMap<Object>()); rsp.setAllValues(list); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); return req; }
Example 13
Source File: CentroidComponentTest.java From query-segmenter with Apache License 2.0 | 5 votes |
private SolrQueryRequest request(ModifiableSolrParams params) { SolrCore core = h.getCore(); SolrRequestHandler handler = core.getRequestHandler(CENTROID_REQUEST_HANDLER); SolrQueryResponse rsp = new SolrQueryResponse(); NamedList<Object> list = new NamedList<Object>(); list.add("responseHeader", new SimpleOrderedMap<Object>()); rsp.setAllValues(list); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); return req; }
Example 14
Source File: BaseTestCase.java From BioSolr with Apache License 2.0 | 5 votes |
public static SolrQueryResponse query(SolrCore core, String handlerName, SolrParams params) { SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequest req = new SolrQueryRequestBase(core, params) { }; try { SolrRequestHandler handler = core.getRequestHandler(handlerName); core.execute(handler, req, rsp); return rsp; } finally { req.close(); } }
Example 15
Source File: SimpleTreeFacetComponentTest.java From BioSolr with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testMultipleResults() { SolrCore core = h.getCore(); ModifiableSolrParams params = new ModifiableSolrParams(); params.add("q", "name:nodeA*"); params.add("facet", "true"); params.add("facet.tree", "true"); params.add("facet.tree.field", "{!ftree childField=child_ids}node_id"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler(requestHandler); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); NamedList results = rsp.getValues(); NamedList facetTree = (NamedList) ((NamedList)(results.get("facet_counts"))).get("facet_trees"); assertNotNull(facetTree); // Check the generated hierarchy - should be three levels deep List<Object> nodes = (List) facetTree.get("node_id"); assertEquals(1, nodes.size()); NamedList level1 = (NamedList) nodes.get(0); assertEquals("A", level1.get("value")); assertEquals(1L, level1.get("count")); assertEquals(6L, level1.get("total")); List level2Nodes = (List)level1.get("hierarchy"); assertEquals(3, level2Nodes.size()); NamedList level2 = (NamedList)level2Nodes.get(0); assertEquals(1L, level2.get("count")); assertEquals(3L, level2.get("total")); List level3Nodes = (List)level2.get("hierarchy"); assertEquals(2, level3Nodes.size()); NamedList level3 = (NamedList)level3Nodes.get(0); assertEquals(1L, level3.get("count")); assertEquals(1L, level3.get("total")); assertNull(level3.get("hierarchy")); }
Example 16
Source File: SimpleTreeFacetComponentTest.java From BioSolr with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testSingleResult() { SolrCore core = h.getCore(); ModifiableSolrParams params = new ModifiableSolrParams(); params.add("q", "name:nodeAAA"); params.add("facet", "true"); params.add("facet.tree", "true"); params.add("facet.tree.field", "{!ftree childField=child_ids}node_id"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler(requestHandler); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); NamedList results = rsp.getValues(); NamedList facetTree = (NamedList) ((NamedList)(results.get("facet_counts"))).get("facet_trees"); assertNotNull(facetTree); // Check the generated hierarchy - should be three levels deep List<Object> nodes = (List) facetTree.get("node_id"); assertEquals(1, nodes.size()); NamedList level1 = (NamedList) nodes.get(0); assertEquals("A", level1.get("value")); assertEquals(0L, level1.get("count")); assertEquals(1L, level1.get("total")); List level2Nodes = (List)level1.get("hierarchy"); NamedList level2 = (NamedList)level2Nodes.get(0); assertEquals("AA", level2.get("value")); assertEquals(0L, level2.get("count")); assertEquals(1L, level2.get("total")); List level3Nodes = (List)level2.get("hierarchy"); NamedList level3 = (NamedList)level3Nodes.get(0); assertEquals("AAA", level3.get("value")); assertEquals(1L, level3.get("count")); assertEquals(1L, level3.get("total")); assertNull(level3.get("hierarchy")); }
Example 17
Source File: SimpleTreeFacetComponentTest.java From BioSolr with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testResultsWithOtherFacets() { SolrCore core = h.getCore(); ModifiableSolrParams params = new ModifiableSolrParams(); params.add("q", "name:nodeA*"); params.add("facet", "true"); params.add("facet.tree", "true"); params.add("facet.tree.field", "{!ftree childField=child_ids}node_id"); params.add("facet.field", "label"); params.add("facet.field", "node_id"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler(requestHandler); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); NamedList results = rsp.getValues(); NamedList facetFields = (NamedList)((NamedList)(results.get("facet_counts"))).get("facet_fields"); assertNotNull(facetFields); assertNotNull(facetFields.get("label")); assertNotNull(facetFields.get("node_id")); NamedList facetTree = (NamedList) ((NamedList)(results.get("facet_counts"))).get("facet_trees"); assertNotNull(facetTree); // Check the generated hierarchy - should be three levels deep List<Object> nodes = (List) facetTree.get("node_id"); assertEquals(1, nodes.size()); NamedList level1 = (NamedList) nodes.get(0); assertEquals("A", level1.get("value")); assertEquals(1L, level1.get("count")); assertEquals(6L, level1.get("total")); List level2Nodes = (List)level1.get("hierarchy"); assertEquals(3, level2Nodes.size()); NamedList level2 = (NamedList)level2Nodes.get(0); assertEquals(1L, level2.get("count")); assertEquals(3L, level2.get("total")); List level3Nodes = (List)level2.get("hierarchy"); assertEquals(2, level3Nodes.size()); NamedList level3 = (NamedList)level3Nodes.get(0); assertEquals(1L, level3.get("count")); assertEquals(1L, level3.get("total")); assertNull(level3.get("hierarchy")); }
Example 18
Source File: SecureAdminHandlers.java From incubator-sentry with Apache License 2.0 | 4 votes |
/** * NOTE: ideally we'd just override the list of admin handlers, but * since AdminHandlers in solr doesn't allow it, let's just copy the * entire function. This is deprecated in Solr 5.0, so we should do something * different with Solr 5.0 anyway. */ @Override public void inform(SolrCore core) { String path = null; for( Map.Entry<String, SolrRequestHandler> entry : core.getRequestHandlers().entrySet() ) { if( entry.getValue() == this ) { path = entry.getKey(); break; } } if( path == null ) { throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "The AdminHandler is not registered with the current core." ); } if( !path.startsWith( "/" ) ) { throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "The AdminHandler needs to be registered to a path. Typically this is '/admin'" ); } // Remove the parent handler core.registerRequestHandler(path, null); if( !path.endsWith( "/" ) ) { path += "/"; } StandardHandler[] list = new StandardHandler[] { new StandardHandler( "luke", new SecureLukeRequestHandler() ), new StandardHandler( "system", new SecureSystemInfoHandler() ), new StandardHandler( "mbeans", new SecureSolrInfoMBeanHandler() ), new StandardHandler( "plugins", new SecurePluginInfoHandler() ), new StandardHandler( "threads", new SecureThreadDumpHandler() ), new StandardHandler( "properties", new SecurePropertiesRequestHandler() ), new StandardHandler( "logging", new SecureLoggingHandler() ), new StandardHandler( "file", new SecureShowFileRequestHandler() ) }; for( StandardHandler handler : list ) { if( core.getRequestHandler( path+handler.name ) == null ) { handler.handler.init( initArgs ); core.registerRequestHandler( path+handler.name, handler.handler ); if( handler.handler instanceof SolrCoreAware ) { ((SolrCoreAware)handler.handler).inform(core); } } } }
Example 19
Source File: TestCrossCoreJoin.java From lucene-solr with Apache License 2.0 | 4 votes |
public static String update(SolrCore core, String xml) throws Exception { DirectSolrConnection connection = new DirectSolrConnection(core); SolrRequestHandler handler = core.getRequestHandler("/update"); return connection.request(handler, null, xml); }
Example 20
Source File: RecoveryStrategy.java From lucene-solr with Apache License 2.0 | 4 votes |
final private void replicate(String nodeName, SolrCore core, ZkNodeProps leaderprops) throws SolrServerException, IOException { final String leaderUrl = getReplicateLeaderUrl(leaderprops); log.info("Attempting to replicate from [{}].", leaderUrl); // send commit commitOnLeader(leaderUrl); // use rep handler directly, so we can do this sync rather than async SolrRequestHandler handler = core.getRequestHandler(ReplicationHandler.PATH); ReplicationHandler replicationHandler = (ReplicationHandler) handler; if (replicationHandler == null) { throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Skipping recovery, no " + ReplicationHandler.PATH + " handler found"); } ModifiableSolrParams solrParams = new ModifiableSolrParams(); solrParams.set(ReplicationHandler.MASTER_URL, leaderUrl); solrParams.set(ReplicationHandler.SKIP_COMMIT_ON_MASTER_VERSION_ZERO, replicaType == Replica.Type.TLOG); // always download the tlogs from the leader when running with cdcr enabled. We need to have all the tlogs // to ensure leader failover doesn't cause missing docs on the target if (core.getUpdateHandler().getUpdateLog() != null && core.getUpdateHandler().getUpdateLog() instanceof CdcrUpdateLog) { solrParams.set(ReplicationHandler.TLOG_FILES, true); } if (isClosed()) return; // we check closed on return boolean success = replicationHandler.doFetch(solrParams, false).getSuccessful(); if (!success) { throw new SolrException(ErrorCode.SERVER_ERROR, "Replication for recovery failed."); } // solrcloud_debug if (log.isDebugEnabled()) { try { RefCounted<SolrIndexSearcher> searchHolder = core .getNewestSearcher(false); SolrIndexSearcher searcher = searchHolder.get(); Directory dir = core.getDirectoryFactory().get(core.getIndexDir(), DirContext.META_DATA, null); try { final IndexCommit commit = core.getDeletionPolicy().getLatestCommit(); if (log.isDebugEnabled()) { log.debug("{} replicated {} from {} gen: {} data: {} index: {} newIndex: {} files: {}" , core.getCoreContainer().getZkController().getNodeName() , searcher.count(new MatchAllDocsQuery()) , leaderUrl , (null == commit ? "null" : commit.getGeneration()) , core.getDataDir() , core.getIndexDir() , core.getNewIndexDir() , Arrays.asList(dir.listAll())); } } finally { core.getDirectoryFactory().release(dir); searchHolder.decref(); } } catch (Exception e) { log.debug("Error in solrcloud_debug block", e); } } }