Search in sources :

Example 56 with FieldType

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

the class FacetRangeProcessor method getRangeCounts.

private SimpleOrderedMap<Object> getRangeCounts() throws IOException {
    final FieldType ft = sf.getType();
    if (ft instanceof TrieField) {
        switch(ft.getNumberType()) {
            case FLOAT:
                calc = new FloatCalc(sf);
                break;
            case DOUBLE:
                calc = new DoubleCalc(sf);
                break;
            case INTEGER:
                calc = new IntCalc(sf);
                break;
            case LONG:
                calc = new LongCalc(sf);
                break;
            case DATE:
                calc = new DateCalc(sf, null);
                break;
            default:
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on tried field of unexpected type:" + freq.field);
        }
    } else {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on field:" + sf);
    }
    createRangeList();
    return getRangeCountsIndexed();
}
Also used : TrieField(org.apache.solr.schema.TrieField) SolrException(org.apache.solr.common.SolrException) FieldType(org.apache.solr.schema.FieldType)

Example 57 with FieldType

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

the class TestLuceneMatchVersion method testStandardTokenizerVersions.

public void testStandardTokenizerVersions() throws Exception {
    assertEquals(DEFAULT_VERSION, solrConfig.luceneMatchVersion);
    final IndexSchema schema = h.getCore().getLatestSchema();
    FieldType type = schema.getFieldType("textDefault");
    TokenizerChain ana = (TokenizerChain) type.getIndexAnalyzer();
    assertEquals(DEFAULT_VERSION, (ana.getTokenizerFactory()).getLuceneMatchVersion());
    assertEquals(DEFAULT_VERSION, (ana.getTokenFilterFactories()[2]).getLuceneMatchVersion());
    type = schema.getFieldType("textTurkishAnalyzerDefault");
    Analyzer ana1 = type.getIndexAnalyzer();
    assertTrue(ana1 instanceof TurkishAnalyzer);
    assertEquals(DEFAULT_VERSION, ana1.getVersion());
}
Also used : IndexSchema(org.apache.solr.schema.IndexSchema) Analyzer(org.apache.lucene.analysis.Analyzer) TurkishAnalyzer(org.apache.lucene.analysis.tr.TurkishAnalyzer) TurkishAnalyzer(org.apache.lucene.analysis.tr.TurkishAnalyzer) FieldType(org.apache.solr.schema.FieldType)

Example 58 with FieldType

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

the class TestReversedWildcardFilterFactory method testCachingInQueryParser.

@Test
public void testCachingInQueryParser() {
    SolrQParser parser = new SolrQParser();
    SolrQueryRequest req = req();
    String[] fields = new String[] { "one", "two", "three" };
    String aField = fields[random().nextInt(fields.length)];
    FieldType type = req.getSchema().getField(aField).getType();
    FieldType typeSpy = spy(type);
    // calling twice 
    parser.getReversedWildcardFilterFactory(typeSpy);
    parser.getReversedWildcardFilterFactory(typeSpy);
    // but it should reach only once 
    verify(typeSpy, times(1)).getIndexAnalyzer();
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) FieldType(org.apache.solr.schema.FieldType) Test(org.junit.Test)

Example 59 with FieldType

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

the class TestTrie method checkPrecisionSteps.

private void checkPrecisionSteps(String fieldType) {
    FieldType type = h.getCore().getLatestSchema().getFieldType(fieldType);
    if (type instanceof TrieField) {
        TrieField field = (TrieField) type;
        assertTrue(field.getPrecisionStep() > 0 && field.getPrecisionStep() < 64);
    }
}
Also used : TrieField(org.apache.solr.schema.TrieField) FieldType(org.apache.solr.schema.FieldType)

Example 60 with FieldType

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

the class PivotFacetProcessor method getSubset.

/**
   * Given a base docset, computes the subset of documents corresponding to the specified pivotValue
   *
   * @param base the set of documents to evaluate relative to
   * @param field the field type used by the pivotValue
   * @param pivotValue String representation of the value, may be null (ie: "missing")
   */
private DocSet getSubset(DocSet base, SchemaField field, String pivotValue) throws IOException {
    FieldType ft = field.getType();
    if (null == pivotValue) {
        Query query = ft.getRangeQuery(null, field, null, null, false, false);
        DocSet hasVal = searcher.getDocSet(query);
        return base.andNot(hasVal);
    } else {
        Query query = ft.getFieldQuery(null, field, pivotValue);
        return searcher.getDocSet(query, base);
    }
}
Also used : Query(org.apache.lucene.search.Query) DocSet(org.apache.solr.search.DocSet) FieldType(org.apache.solr.schema.FieldType)

Aggregations

FieldType (org.apache.solr.schema.FieldType)93 SchemaField (org.apache.solr.schema.SchemaField)37 SolrException (org.apache.solr.common.SolrException)29 ArrayList (java.util.ArrayList)23 BytesRef (org.apache.lucene.util.BytesRef)23 NamedList (org.apache.solr.common.util.NamedList)23 IOException (java.io.IOException)18 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)15 IndexSchema (org.apache.solr.schema.IndexSchema)14 Query (org.apache.lucene.search.Query)13 BytesRefBuilder (org.apache.lucene.util.BytesRefBuilder)13 Analyzer (org.apache.lucene.analysis.Analyzer)12 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)10 CharsRefBuilder (org.apache.lucene.util.CharsRefBuilder)10 StrField (org.apache.solr.schema.StrField)8 HashMap (java.util.HashMap)7 List (java.util.List)7 Map (java.util.Map)7 DocIterator (org.apache.solr.search.DocIterator)7 DocList (org.apache.solr.search.DocList)7