Search in sources :

Example 6 with IndexSchema

use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.

the class TestUnifiedSolrHighlighter method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    System.setProperty("filterCache.enabled", "false");
    System.setProperty("queryResultCache.enabled", "false");
    // this is why we use this particular solrconfig
    System.setProperty("documentCache.enabled", "true");
    initCore("solrconfig-cache-enable-disable.xml", "schema-unifiedhighlight.xml");
    // test our config is sane, just to be sure:
    // 'text' and 'text3' should have offsets, 'text2' should not
    IndexSchema schema = h.getCore().getLatestSchema();
    assertTrue(schema.getField("text").storeOffsetsWithPositions());
    assertTrue(schema.getField("text3").storeOffsetsWithPositions());
    assertFalse(schema.getField("text2").storeOffsetsWithPositions());
}
Also used : IndexSchema(org.apache.solr.schema.IndexSchema) BeforeClass(org.junit.BeforeClass)

Example 7 with IndexSchema

use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.

the class TestPostingsSolrHighlighter method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    initCore("solrconfig-postingshighlight.xml", "schema-postingshighlight.xml");
    // test our config is sane, just to be sure:
    // postingshighlighter should be used
    SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
    assertTrue("wrong highlighter: " + highlighter.getClass(), highlighter instanceof PostingsSolrHighlighter);
    // 'text' and 'text3' should have offsets, 'text2' should not
    IndexSchema schema = h.getCore().getLatestSchema();
    assertTrue(schema.getField("text").storeOffsetsWithPositions());
    assertTrue(schema.getField("text3").storeOffsetsWithPositions());
    assertFalse(schema.getField("text2").storeOffsetsWithPositions());
}
Also used : IndexSchema(org.apache.solr.schema.IndexSchema) BeforeClass(org.junit.BeforeClass)

Example 8 with IndexSchema

use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.

the class TestRecovery method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    savedFactory = System.getProperty("solr.DirectoryFactory");
    System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
    initCore("solrconfig-tlog.xml", "schema15.xml");
    // validate that the schema was not changed to an unexpected state
    IndexSchema schema = h.getCore().getLatestSchema();
    assertTrue(schema.getFieldOrNull("_version_").hasDocValues() && !schema.getFieldOrNull("_version_").indexed() && !schema.getFieldOrNull("_version_").stored());
}
Also used : IndexSchema(org.apache.solr.schema.IndexSchema) BeforeClass(org.junit.BeforeClass)

Example 9 with IndexSchema

use of org.apache.solr.schema.IndexSchema 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 10 with IndexSchema

use of org.apache.solr.schema.IndexSchema 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)

Aggregations

IndexSchema (org.apache.solr.schema.IndexSchema)109 SolrInputDocument (org.apache.solr.common.SolrInputDocument)41 SchemaField (org.apache.solr.schema.SchemaField)31 HashMap (java.util.HashMap)15 SolrException (org.apache.solr.common.SolrException)13 FieldType (org.apache.solr.schema.FieldType)13 Date (java.util.Date)12 LinkedHashMap (java.util.LinkedHashMap)12 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)12 IOException (java.io.IOException)11 NamedList (org.apache.solr.common.util.NamedList)11 ArrayList (java.util.ArrayList)10 SolrIndexSearcher (org.apache.solr.search.SolrIndexSearcher)10 DateTime (org.joda.time.DateTime)10 Document (org.apache.lucene.document.Document)8 SolrParams (org.apache.solr.common.params.SolrParams)8 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)8 Test (org.junit.Test)7 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)6 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)6