Search in sources :

Example 1 with SolrConfig

use of org.apache.solr.core.SolrConfig in project lucene-solr by apache.

the class XSLTResponseWriter method getTransformer.

/** Get Transformer from request context, or from TransformerProvider.
   *  This allows either getContentType(...) or write(...) to instantiate the Transformer,
   *  depending on which one is called first, then the other one reuses the same Transformer
   */
protected Transformer getTransformer(SolrQueryRequest request) throws IOException {
    final String xslt = request.getParams().get(CommonParams.TR, null);
    if (xslt == null) {
        throw new IOException("'" + CommonParams.TR + "' request parameter is required to use the XSLTResponseWriter");
    }
    // not the cleanest way to achieve this
    SolrConfig solrConfig = request.getCore().getSolrConfig();
    // no need to synchronize access to context, right? 
    // Nothing else happens with it at the same time
    final Map<Object, Object> ctx = request.getContext();
    Transformer result = (Transformer) ctx.get(CONTEXT_TRANSFORMER_KEY);
    if (result == null) {
        result = TransformerProvider.instance.getTransformer(solrConfig, xslt, xsltCacheLifetimeSeconds.intValue());
        result.setErrorListener(xmllog);
        ctx.put(CONTEXT_TRANSFORMER_KEY, result);
    }
    return result;
}
Also used : SolrConfig(org.apache.solr.core.SolrConfig) Transformer(javax.xml.transform.Transformer) IOException(java.io.IOException)

Example 2 with SolrConfig

use of org.apache.solr.core.SolrConfig in project lucene-solr by apache.

the class SolrIndexConfigTest method testTieredMPSolrIndexConfigCreation.

@Test
public void testTieredMPSolrIndexConfigCreation() throws Exception {
    String solrConfigFileName = solrConfigFileNameTieredMergePolicyFactory;
    SolrConfig solrConfig = new SolrConfig(instanceDir, solrConfigFileName, null);
    SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);
    IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema(schemaFileName, solrConfig);
    h.getCore().setLatestSchema(indexSchema);
    IndexWriterConfig iwc = solrIndexConfig.toIndexWriterConfig(h.getCore());
    assertNotNull("null mp", iwc.getMergePolicy());
    assertTrue("mp is not TieredMergePolicy", iwc.getMergePolicy() instanceof TieredMergePolicy);
    TieredMergePolicy mp = (TieredMergePolicy) iwc.getMergePolicy();
    assertEquals("mp.maxMergeAtOnceExplicit", 19, mp.getMaxMergeAtOnceExplicit());
    assertEquals("mp.segmentsPerTier", 9, (int) mp.getSegmentsPerTier());
    assertNotNull("null ms", iwc.getMergeScheduler());
    assertTrue("ms is not CMS", iwc.getMergeScheduler() instanceof ConcurrentMergeScheduler);
    ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler) iwc.getMergeScheduler();
    assertEquals("ms.maxMergeCount", 987, ms.getMaxMergeCount());
    assertEquals("ms.maxThreadCount", 42, ms.getMaxThreadCount());
}
Also used : TieredMergePolicy(org.apache.lucene.index.TieredMergePolicy) SolrConfig(org.apache.solr.core.SolrConfig) IndexSchema(org.apache.solr.schema.IndexSchema) ConcurrentMergeScheduler(org.apache.lucene.index.ConcurrentMergeScheduler) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Test(org.junit.Test)

Example 3 with SolrConfig

use of org.apache.solr.core.SolrConfig in project lucene-solr by apache.

the class SolrIndexConfigTest method testMergedSegmentWarmerIndexConfigCreation.

public void testMergedSegmentWarmerIndexConfigCreation() throws Exception {
    SolrConfig solrConfig = new SolrConfig(instanceDir, solrConfigFileNameWarmerRandomMergePolicyFactory, null);
    SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);
    assertNotNull(solrIndexConfig);
    assertNotNull(solrIndexConfig.mergedSegmentWarmerInfo);
    assertEquals(SimpleMergedSegmentWarmer.class.getName(), solrIndexConfig.mergedSegmentWarmerInfo.className);
    IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema(schemaFileName, solrConfig);
    h.getCore().setLatestSchema(indexSchema);
    IndexWriterConfig iwc = solrIndexConfig.toIndexWriterConfig(h.getCore());
    assertEquals(SimpleMergedSegmentWarmer.class, iwc.getMergedSegmentWarmer().getClass());
}
Also used : SolrConfig(org.apache.solr.core.SolrConfig) SimpleMergedSegmentWarmer(org.apache.lucene.index.SimpleMergedSegmentWarmer) IndexSchema(org.apache.solr.schema.IndexSchema) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 4 with SolrConfig

use of org.apache.solr.core.SolrConfig in project lucene-solr by apache.

the class SolrIndexConfigTest method testSortingMPSolrIndexConfigCreation.

public void testSortingMPSolrIndexConfigCreation() throws Exception {
    final String expectedFieldName = "timestamp_i_dvo";
    final SortField.Type expectedFieldType = SortField.Type.INT;
    final boolean expectedFieldSortDescending = true;
    SolrConfig solrConfig = new SolrConfig(instanceDir, solrConfigFileNameSortingMergePolicyFactory, null);
    SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);
    assertNotNull(solrIndexConfig);
    IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema(schemaFileName, solrConfig);
    h.getCore().setLatestSchema(indexSchema);
    IndexWriterConfig iwc = solrIndexConfig.toIndexWriterConfig(h.getCore());
    final MergePolicy mergePolicy = iwc.getMergePolicy();
    assertNotNull("null mergePolicy", mergePolicy);
    assertTrue("mergePolicy (" + mergePolicy + ") is not a SortingMergePolicy", mergePolicy instanceof SortingMergePolicy);
    final SortingMergePolicy sortingMergePolicy = (SortingMergePolicy) mergePolicy;
    final Sort expected = new Sort(new SortField(expectedFieldName, expectedFieldType, expectedFieldSortDescending));
    final Sort actual = sortingMergePolicy.getSort();
    assertEquals("SortingMergePolicy.getSort", expected, actual);
}
Also used : SolrConfig(org.apache.solr.core.SolrConfig) SortingMergePolicy(org.apache.solr.index.SortingMergePolicy) MergePolicy(org.apache.lucene.index.MergePolicy) TieredMergePolicy(org.apache.lucene.index.TieredMergePolicy) SortingMergePolicy(org.apache.solr.index.SortingMergePolicy) Sort(org.apache.lucene.search.Sort) SortField(org.apache.lucene.search.SortField) IndexSchema(org.apache.solr.schema.IndexSchema) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 5 with SolrConfig

use of org.apache.solr.core.SolrConfig in project lucene-solr by apache.

the class PrimitiveFieldTypeTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    // set some system properties for use by tests
    // schema12 doesn't support _version_
    System.setProperty("enable.update.log", "false");
    System.setProperty("solr.test.sys.prop1", "propone");
    System.setProperty("solr.test.sys.prop2", "proptwo");
    System.setProperty("solr.allow.unsafe.resourceloading", "true");
    initMap = new HashMap<>();
    config = new SolrConfig(new SolrResourceLoader(TEST_PATH().resolve("collection1")), testConfHome + "solrconfig.xml", null);
}
Also used : SolrResourceLoader(org.apache.solr.core.SolrResourceLoader) SolrConfig(org.apache.solr.core.SolrConfig)

Aggregations

SolrConfig (org.apache.solr.core.SolrConfig)13 IndexSchema (org.apache.solr.schema.IndexSchema)8 SolrResourceLoader (org.apache.solr.core.SolrResourceLoader)5 IOException (java.io.IOException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)3 SolrCore (org.apache.solr.core.SolrCore)3 SAXException (org.xml.sax.SAXException)3 File (java.io.File)2 Transformer (javax.xml.transform.Transformer)2 TieredMergePolicy (org.apache.lucene.index.TieredMergePolicy)2 EmbeddedSolrServer (org.apache.solr.client.solrj.embedded.EmbeddedSolrServer)2 CoreContainer (org.apache.solr.core.CoreContainer)2 CoreDescriptor (org.apache.solr.core.CoreDescriptor)2 Test (org.junit.Test)2 InputSource (org.xml.sax.InputSource)2 Properties (java.util.Properties)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 ConcurrentMergeScheduler (org.apache.lucene.index.ConcurrentMergeScheduler)1 MergePolicy (org.apache.lucene.index.MergePolicy)1