Search in sources :

Example 46 with IndexSchema

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

the class TestSolr4Spatial method testSpatialConfig.

@Test
public void testSpatialConfig() throws Exception {
    try (SolrCore core = h.getCoreInc()) {
        IndexSchema schema = core.getLatestSchema();
        // BBox Config
        // Make sure the subfields are not stored
        SchemaField sub = schema.getField("bbox" + BBoxStrategy.SUFFIX_MINX);
        assertFalse(sub.stored());
        // Make sure solr field type is also not stored
        BBoxField bbox = (BBoxField) schema.getField("bbox").getType();
        BBoxStrategy strategy = bbox.getStrategy("bbox");
        assertFalse(strategy.getFieldType().stored());
    }
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) BBoxStrategy(org.apache.solr.legacy.BBoxStrategy) SolrCore(org.apache.solr.core.SolrCore) BBoxField(org.apache.solr.schema.BBoxField) IndexSchema(org.apache.solr.schema.IndexSchema) Test(org.junit.Test)

Example 47 with IndexSchema

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

the class TestUnifiedSolrHighlighter method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    System.setProperty("filterCache.enabled", "false");
    System.setProperty("queryResultCache.enabled", "false");
    // this is why we use this particular solrconfig
    System.setProperty("documentCache.enabled", "true");
    initCore("solrconfig-cache-enable-disable.xml", "schema-unifiedhighlight.xml");
    // test our config is sane, just to be sure:
    // 'text' and 'text3' should have offsets, 'text2' should not
    IndexSchema schema = h.getCore().getLatestSchema();
    assertTrue(schema.getField("text").storeOffsetsWithPositions());
    assertTrue(schema.getField("text3").storeOffsetsWithPositions());
    assertFalse(schema.getField("text2").storeOffsetsWithPositions());
}
Also used : IndexSchema(org.apache.solr.schema.IndexSchema) BeforeClass(org.junit.BeforeClass)

Example 48 with IndexSchema

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

the class TestPostingsSolrHighlighter method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    initCore("solrconfig-postingshighlight.xml", "schema-postingshighlight.xml");
    // test our config is sane, just to be sure:
    // postingshighlighter should be used
    SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
    assertTrue("wrong highlighter: " + highlighter.getClass(), highlighter instanceof PostingsSolrHighlighter);
    // 'text' and 'text3' should have offsets, 'text2' should not
    IndexSchema schema = h.getCore().getLatestSchema();
    assertTrue(schema.getField("text").storeOffsetsWithPositions());
    assertTrue(schema.getField("text3").storeOffsetsWithPositions());
    assertFalse(schema.getField("text2").storeOffsetsWithPositions());
}
Also used : IndexSchema(org.apache.solr.schema.IndexSchema) BeforeClass(org.junit.BeforeClass)

Example 49 with IndexSchema

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

the class ClassificationUpdateProcessorFactory method getInstance.

@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {
    String trainingFilterQueryString = (params.get(KNN_FILTER_QUERY));
    try {
        if (trainingFilterQueryString != null && !trainingFilterQueryString.isEmpty()) {
            Query trainingFilterQuery = this.parseFilterQuery(trainingFilterQueryString, params, req);
            classificationParams.setTrainingFilterQuery(trainingFilterQuery);
        }
    } catch (SyntaxError | RuntimeException syntaxError) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Classification UpdateProcessor Training Filter Query: '" + trainingFilterQueryString + "' is not supported", syntaxError);
    }
    IndexSchema schema = req.getSchema();
    IndexReader indexReader = req.getSearcher().getIndexReader();
    return new ClassificationUpdateProcessor(classificationParams, next, indexReader, schema);
}
Also used : Query(org.apache.lucene.search.Query) SyntaxError(org.apache.solr.search.SyntaxError) IndexReader(org.apache.lucene.index.IndexReader) IndexSchema(org.apache.solr.schema.IndexSchema) SolrException(org.apache.solr.common.SolrException)

Example 50 with IndexSchema

use of org.apache.solr.schema.IndexSchema in project SearchServices by Alfresco.

the class TestPostingsSolrHighlighter method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    initAlfrescoCore("schema.xml");
    // test our config is sane, just to be sure:
    // postingshighlighter should be used
    SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
    assertTrue("wrong highlighter: " + highlighter.getClass(), highlighter instanceof AlfrescoSolrHighlighter);
    // 'text' and 'text3' should have offsets, 'text2' should not
    IndexSchema schema = h.getCore().getLatestSchema();
    assertTrue(schema.getField("text").storeOffsetsWithPositions());
    assertTrue(schema.getField("text3").storeOffsetsWithPositions());
    assertFalse(schema.getField("text2").storeOffsetsWithPositions());
}
Also used : SolrHighlighter(org.apache.solr.highlight.SolrHighlighter) PostingsSolrHighlighter(org.apache.solr.highlight.PostingsSolrHighlighter) AlfrescoSolrHighlighter(org.apache.solr.handler.component.AlfrescoSolrHighlighter) AlfrescoSolrHighlighter(org.apache.solr.handler.component.AlfrescoSolrHighlighter) IndexSchema(org.apache.solr.schema.IndexSchema) BeforeClass(org.junit.BeforeClass)

Aggregations

IndexSchema (org.apache.solr.schema.IndexSchema)116 SolrInputDocument (org.apache.solr.common.SolrInputDocument)42 SchemaField (org.apache.solr.schema.SchemaField)34 HashMap (java.util.HashMap)16 SolrException (org.apache.solr.common.SolrException)15 IOException (java.io.IOException)14 FieldType (org.apache.solr.schema.FieldType)14 SolrIndexSearcher (org.apache.solr.search.SolrIndexSearcher)13 Date (java.util.Date)12 LinkedHashMap (java.util.LinkedHashMap)12 NamedList (org.apache.solr.common.util.NamedList)12 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)12 ArrayList (java.util.ArrayList)11 Document (org.apache.lucene.document.Document)11 SolrParams (org.apache.solr.common.params.SolrParams)11 DateTime (org.joda.time.DateTime)10 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)9 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)9 SolrConfig (org.apache.solr.core.SolrConfig)8 Test (org.junit.Test)7