use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class ParsingFieldUpdateProcessorsTest method testParseDateExplicitNotInSchemaSelector.
public void testParseDateExplicitNotInSchemaSelector() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
assertNull(schema.getFieldOrNull("not_in_schema"));
String dateString = "2010-11-12T13:14:15.168Z";
DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime();
DateTime dateTime = dateTimeFormatter.parseDateTime(dateString);
SolrInputDocument d = processAdd("parse-date-explicit-not-in-schema-selector-no-run-processor", doc(f("id", "88"), f("not_in_schema", dateString)));
assertNotNull(d);
assertTrue(d.getFieldValue("not_in_schema") instanceof Date);
assertEquals(dateTime.getMillis(), ((Date) d.getFieldValue("not_in_schema")).getTime());
}
use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class ParsingFieldUpdateProcessorsTest method testParseUSPacificDate.
public void testParseUSPacificDate() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
assertNull(schema.getFieldOrNull("not_in_schema"));
// Interpreted as 00:00 US Pacific Daylight Time = UTC+07:00
String dateString = "8/9/2010";
String dateStringUTC = "2010-08-09T07:00:00.000Z";
SolrInputDocument d = processAdd("US-Pacific-parse-date-no-run-processor", doc(f("id", "288"), f("not_in_schema", dateString)));
assertNotNull(d);
assertTrue(d.getFieldValue("not_in_schema") instanceof Date);
assertEquals(dateStringUTC, (new DateTime(((Date) d.getFieldValue("not_in_schema")).getTime(), DateTimeZone.UTC)).toString());
}
use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class ParsingFieldUpdateProcessorsTest method testFailedParseMixedFloat.
public void testFailedParseMixedFloat() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
assertNull(schema.getFieldOrNull("not_in_schema"));
Map<Object, Object> mixed = new HashMap<>();
Long longVal = 294423L;
mixed.put(85L, "85");
// Float-typed field value
mixed.put(longVal, longVal);
mixed.put(-2894518L, "-2,894,518");
mixed.put(1879472193L, "1,879,472,193");
SolrInputDocument d = processAdd("parse-float-no-run-processor", doc(f("id", "7205"), f("not_in_schema", mixed.values())));
assertNotNull(d);
boolean foundLong = false;
for (Object o : d.getFieldValues("not_in_schema")) {
if (longVal == o) {
foundLong = true;
} else {
assertTrue(o instanceof String);
}
mixed.values().remove(o);
}
assertTrue(foundLong);
assertTrue(mixed.isEmpty());
}
use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class ParsingFieldUpdateProcessorsTest method testParseFrenchDate.
public void testParseFrenchDate() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
assertNull(schema.getFieldOrNull("not_in_schema"));
String frenchDateString = "le vendredi 15 janvier 2010";
String dateString = "2010-01-15T00:00:00.000Z";
DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime();
DateTime dateTime = dateTimeFormatter.parseDateTime(dateString);
SolrInputDocument d = processAdd("parse-french-date-UTC-defaultTimeZone-no-run-processor", doc(f("id", "88"), f("not_in_schema", frenchDateString)));
assertNotNull(d);
assertTrue(d.getFieldValue("not_in_schema") instanceof Date);
assertEquals(dateTime.getMillis(), ((Date) d.getFieldValue("not_in_schema")).getTime());
}
use of org.apache.solr.schema.IndexSchema in project lucene-solr by apache.
the class ParsingFieldUpdateProcessorsTest method testFailedParseMixedDouble.
public void testFailedParseMixedDouble() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
assertNull(schema.getFieldOrNull("not_in_schema"));
Map<Object, Object> mixed = new HashMap<>();
Long longVal = 294423L;
mixed.put(85, "85.0");
// Float-typed field value
mixed.put(longVal, longVal);
mixed.put(-2894.518, "-2,894.518");
mixed.put(187947.2193, "187,947.2193");
SolrInputDocument d = processAdd("parse-double-no-run-processor", doc(f("id", "7206"), f("not_in_schema", mixed.values())));
assertNotNull(d);
boolean foundLong = false;
for (Object o : d.getFieldValues("not_in_schema")) {
if (longVal == o) {
foundLong = true;
} else {
assertTrue(o instanceof String);
}
mixed.values().remove(o);
}
assertTrue(foundLong);
assertTrue(mixed.isEmpty());
}
Aggregations