use of org.apache.solr.schema.SchemaField in project lucene-solr by apache.
the class AtomicUpdateDocumentMerger method doSet.
protected void doSet(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal) {
SchemaField sf = schema.getField(sif.getName());
toDoc.setField(sif.getName(), sf.getType().toNativeType(fieldVal));
}
use of org.apache.solr.schema.SchemaField in project lucene-solr by apache.
the class TestIntervalFaceting method assertBadInterval.
private void assertBadInterval(String fieldName, String intervalStr, String errorMsg) {
SchemaField f = h.getCore().getLatestSchema().getField(fieldName);
try {
new FacetInterval(f, intervalStr, new ModifiableSolrParams());
fail("Expecting SyntaxError for interval String: " + intervalStr);
} catch (SyntaxError e) {
assertTrue("Unexpected error message for interval String: " + intervalStr + ": " + e.getMessage(), e.getMessage().contains(errorMsg));
}
}
use of org.apache.solr.schema.SchemaField in project lucene-solr by apache.
the class TestIntervalFaceting method assertStringInterval.
private void assertStringInterval(String fieldName, String intervalStr, String expectedStart, String expectedEnd) throws SyntaxError {
SchemaField f = h.getCore().getLatestSchema().getField(fieldName);
FacetInterval interval = new FacetInterval(f, intervalStr, new ModifiableSolrParams());
assertEquals("Expected start " + expectedStart + " but found " + f.getType().toObject(f, interval.start), interval.start, new BytesRef(f.getType().toInternal(expectedStart)));
assertEquals("Expected end " + expectedEnd + " but found " + f.getType().toObject(f, interval.end), interval.end, new BytesRef(f.getType().toInternal(expectedEnd)));
}
use of org.apache.solr.schema.SchemaField in project lucene-solr by apache.
the class TestIntervalFaceting method assertInterval.
private void assertInterval(String fieldName, String intervalStr, long[] included, long[] lowerThanStart, long[] graterThanEnd) throws SyntaxError {
SchemaField f = h.getCore().getLatestSchema().getField(fieldName);
FacetInterval interval = new FacetInterval(f, intervalStr, new ModifiableSolrParams());
for (long l : included) {
assertEquals("Value " + l + " should be INCLUDED for interval" + interval, IntervalCompareResult.INCLUDED, interval.includes(l));
}
for (long l : lowerThanStart) {
assertEquals("Value " + l + " should be LOWER_THAN_START for inteval " + interval, IntervalCompareResult.LOWER_THAN_START, interval.includes(l));
}
for (long l : graterThanEnd) {
assertEquals("Value " + l + " should be GRATER_THAN_END for inteval " + interval, IntervalCompareResult.GREATER_THAN_END, interval.includes(l));
}
}
use of org.apache.solr.schema.SchemaField in project lucene-solr by apache.
the class TestFacetMethods method testNumericSingleValuedNoDV.
@Test
public void testNumericSingleValuedNoDV() {
SchemaField field = new SchemaField("field", new TrieIntField(), 0, null);
// only works with FCS for mincount = 0, UIF for count > 0 is fine
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, null, 0));
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.ENUM, 0));
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FC, 0));
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.UIF, 0));
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FCS, 0));
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, null, 1));
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.ENUM, 1));
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FC, 1));
assertEquals(SimpleFacets.FacetMethod.UIF, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.UIF, 1));
assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FCS, 1));
}
Aggregations