use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class TestConfig method testDefaults.
// If defaults change, add test methods to cover each version
@Test
public void testDefaults() throws Exception {
int numDefaultsTested = 0;
int numNullDefaults = 0;
SolrConfig sc = new SolrConfig(new SolrResourceLoader(TEST_PATH().resolve("collection1")), "solrconfig-defaults.xml", null);
SolrIndexConfig sic = sc.indexConfig;
++numDefaultsTested;
assertEquals("default useCompoundFile", false, sic.useCompoundFile);
++numDefaultsTested;
assertEquals("default maxBufferedDocs", -1, sic.maxBufferedDocs);
++numDefaultsTested;
assertEquals("default ramBufferSizeMB", 100.0D, sic.ramBufferSizeMB, 0.0D);
++numDefaultsTested;
assertEquals("default writeLockTimeout", -1, sic.writeLockTimeout);
++numDefaultsTested;
assertEquals("default LockType", DirectoryFactory.LOCK_TYPE_NATIVE, sic.lockType);
++numDefaultsTested;
assertEquals("default infoStream", InfoStream.NO_OUTPUT, sic.infoStream);
++numDefaultsTested;
assertNotNull("default metrics", sic.metricsInfo);
++numDefaultsTested;
++numNullDefaults;
assertNull("default mergePolicyFactoryInfo", sic.mergePolicyFactoryInfo);
++numDefaultsTested;
++numNullDefaults;
assertNull("default mergeSchedulerInfo", sic.mergeSchedulerInfo);
++numDefaultsTested;
++numNullDefaults;
assertNull("default mergedSegmentWarmerInfo", sic.mergedSegmentWarmerInfo);
IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", solrConfig);
IndexWriterConfig iwc = sic.toIndexWriterConfig(h.getCore());
assertNotNull("null mp", iwc.getMergePolicy());
assertTrue("mp is not TieredMergePolicy", iwc.getMergePolicy() instanceof TieredMergePolicy);
assertNotNull("null ms", iwc.getMergeScheduler());
assertTrue("ms is not CMS", iwc.getMergeScheduler() instanceof ConcurrentMergeScheduler);
assertNull("non-null mergedSegmentWarmer", iwc.getMergedSegmentWarmer());
final int numDefaultsMapped = sic.toMap(new LinkedHashMap<>()).size();
assertEquals("numDefaultsTested vs. numDefaultsMapped+numNullDefaults =" + sic.toMap(new LinkedHashMap<>()).keySet(), numDefaultsTested, numDefaultsMapped + numNullDefaults);
}
use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class UninvertDocValuesMergePolicyTest method implUpdateSchemaField.
private static void implUpdateSchemaField(TestHarness h, String fieldName, IntUnaryOperator propertiesModifier) {
try (SolrCore core = h.getCoreInc()) {
// Add docvalues to the field type
IndexSchema schema = core.getLatestSchema();
SchemaField oldSchemaField = schema.getField(fieldName);
SchemaField newSchemaField = new SchemaField(fieldName, oldSchemaField.getType(), propertiesModifier.applyAsInt(oldSchemaField.getProperties()), oldSchemaField.getDefaultValue());
schema.getFields().put(fieldName, newSchemaField);
}
}
use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class LargeFieldTest method initManagedSchemaCore.
@BeforeClass
public static void initManagedSchemaCore() throws Exception {
// This testing approach means no schema file or per-test temp solr-home!
System.setProperty("managed.schema.mutable", "true");
System.setProperty("managed.schema.resourceName", "schema-one-field-no-dynamic-field-unique-key.xml");
System.setProperty("enable.update.log", "false");
System.setProperty("documentCache.enabled", "true");
System.setProperty("enableLazyFieldLoading", "true");
initCore("solrconfig-managed-schema.xml", "ignoredSchemaName");
// TODO SOLR-10229 will make this easier
// don't write to test resource dir
boolean PERSIST_FALSE = false;
IndexSchema schema = h.getCore().getLatestSchema();
schema = schema.addFieldTypes(Collections.singletonList(// redundant; TODO improve api
schema.newFieldType(// redundant; TODO improve api
"textType", // redundant; TODO improve api
"solr.TextField", map("name", "textType", "class", "solr.TextField", "analyzer", map("class", "org.apache.lucene.analysis.standard.StandardAnalyzer")))), PERSIST_FALSE);
schema = schema.addFields(Arrays.asList(schema.newField(LAZY_FIELD, "textType", map()), schema.newField(BIG_FIELD, "textType", map("large", true))), Collections.emptyMap(), PERSIST_FALSE);
h.getCore().setLatestSchema(schema);
}
use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class ParsingFieldUpdateProcessorsTest method testParseDoubleNonRootLocale.
public void testParseDoubleNonRootLocale() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
// should match dynamic field "*_d"
assertNotNull(schema.getFieldOrNull("double_d"));
assertNull(schema.getFieldOrNull("not_in_schema"));
double value = 10898.83491;
String doubleString1 = "10898,83491";
// no-break space: U+00A0
String doubleString2 = "10 898,83491";
SolrInputDocument d = processAdd("parse-double-french-no-run-processor", doc(f("id", "140"), f("double_d", doubleString1), f("not_in_schema", doubleString2)));
assertNotNull(d);
assertTrue(d.getFieldValue("double_d") instanceof Double);
assertEquals(value, (Double) d.getFieldValue("double_d"), EPSILON);
assertTrue(d.getFieldValue("not_in_schema") instanceof Double);
assertEquals(value, (Double) d.getFieldValue("not_in_schema"), EPSILON);
}
use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class ParsingFieldUpdateProcessorsTest method testParseDateExplicitTypeClassSelector.
public void testParseDateExplicitTypeClassSelector() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
assertNotNull(schema.getFieldOrNull("date_dt"));
String dateString = "2010-11-12T13:14:15.168Z";
DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime();
DateTime dateTime = dateTimeFormatter.parseDateTime(dateString);
SolrInputDocument d;
if (schema.getField("date_dt").getType().isPointField()) {
d = processAdd("parse-date-explicit-typeclass-point-selector-no-run-processor", doc(f("id", "77"), f("date_dt", dateString)));
} else {
d = processAdd("parse-date-explicit-typeclass-selector-no-run-processor", doc(f("id", "77"), f("date_dt", dateString)));
}
assertNotNull(d);
assertTrue(d.getFieldValue("date_dt") instanceof Date);
assertEquals(dateTime.getMillis(), ((Date) d.getFieldValue("date_dt")).getTime());
}
Aggregations