Search in sources :

Example 71 with SchemaField

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));
}
Also used : SchemaField(org.apache.solr.schema.SchemaField)

Example 72 with SchemaField

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));
    }
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) SyntaxError(org.apache.solr.search.SyntaxError) FacetInterval(org.apache.solr.request.IntervalFacets.FacetInterval) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 73 with SchemaField

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)));
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) FacetInterval(org.apache.solr.request.IntervalFacets.FacetInterval) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) BytesRef(org.apache.lucene.util.BytesRef)

Example 74 with SchemaField

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));
    }
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) FacetInterval(org.apache.solr.request.IntervalFacets.FacetInterval) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 75 with SchemaField

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));
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) TrieIntField(org.apache.solr.schema.TrieIntField) Test(org.junit.Test)

Aggregations

SchemaField (org.apache.solr.schema.SchemaField)167 SolrException (org.apache.solr.common.SolrException)45 FieldType (org.apache.solr.schema.FieldType)37 ArrayList (java.util.ArrayList)36 IndexSchema (org.apache.solr.schema.IndexSchema)32 NamedList (org.apache.solr.common.util.NamedList)27 BytesRef (org.apache.lucene.util.BytesRef)20 IOException (java.io.IOException)17 Query (org.apache.lucene.search.Query)17 SolrIndexSearcher (org.apache.solr.search.SolrIndexSearcher)17 HashMap (java.util.HashMap)16 Document (org.apache.lucene.document.Document)16 SolrParams (org.apache.solr.common.params.SolrParams)16 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)16 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)15 IndexableField (org.apache.lucene.index.IndexableField)14 Map (java.util.Map)13 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)13 SolrDocument (org.apache.solr.common.SolrDocument)13 SolrInputDocument (org.apache.solr.common.SolrInputDocument)13