Search in sources :

Example 76 with SchemaField

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

the class TestFacetMethods method testNumericMultiValuedDV.

@Test
public void testNumericMultiValuedDV() {
    SchemaField field = new SchemaField("field", new TrieIntField(), DOC_VALUES ^ MULTIVALUED, null);
    // default is FC, can't use ENUM due to trie-field terms, can't use FCS because of multivalues
    // default value is FC
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, null, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.ENUM, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FCS, 0));
    assertEquals(SimpleFacets.FacetMethod.UIF, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.UIF, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FC, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, null, 1));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.ENUM, 1));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FCS, 1));
    assertEquals(SimpleFacets.FacetMethod.UIF, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.UIF, 1));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FC, 1));
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) TrieIntField(org.apache.solr.schema.TrieIntField) Test(org.junit.Test)

Example 77 with SchemaField

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

the class TestFacetMethods method testTextMultiValuedDV.

@Test
public void testTextMultiValuedDV() {
    SchemaField field = new SchemaField("field", new StrField(), DOC_VALUES ^ MULTIVALUED, null);
    // default is FC, can't use FCS because of multivalues
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, null, 0));
    assertEquals(SimpleFacets.FacetMethod.ENUM, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.ENUM, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FCS, 0));
    assertEquals(SimpleFacets.FacetMethod.UIF, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.UIF, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FC, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, null, 1));
    assertEquals(SimpleFacets.FacetMethod.ENUM, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.ENUM, 1));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FCS, 1));
    assertEquals(SimpleFacets.FacetMethod.UIF, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.UIF, 1));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FC, 1));
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) StrField(org.apache.solr.schema.StrField) Test(org.junit.Test)

Example 78 with SchemaField

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

the class TestFacetMethods method testPointFields.

@Test
public void testPointFields() {
    // Methods other than FCS are not currently supported for PointFields
    SchemaField field = new SchemaField("foo", new IntPointField());
    assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, null, 0));
    assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, FacetMethod.ENUM, 0));
    assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, FacetMethod.FC, 0));
    assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, FacetMethod.FCS, 0));
    //MultiValued
    field = new SchemaField("fooMV", new IntPointField(), 0x00000200, "0");
    assertTrue(field.multiValued());
    assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, null, 0));
    assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, FacetMethod.ENUM, 0));
    assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, FacetMethod.FC, 0));
    assertEquals(SimpleFacets.FacetMethod.FCS, SimpleFacets.selectFacetMethod(field, FacetMethod.FCS, 0));
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) IntPointField(org.apache.solr.schema.IntPointField) Test(org.junit.Test)

Example 79 with SchemaField

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

the class TestFacetMethods method testNumericMultiValuedNoDV.

@Test
public void testNumericMultiValuedNoDV() {
    SchemaField field = new SchemaField("field", new TrieIntField(), MULTIVALUED, null);
    // only works with FC for mincount = 0, UIF for count > 1 is fine
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, null, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.ENUM, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FCS, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.UIF, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FC, 0));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, null, 1));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.ENUM, 1));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FCS, 1));
    assertEquals(SimpleFacets.FacetMethod.UIF, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.UIF, 1));
    assertEquals(SimpleFacets.FacetMethod.FC, SimpleFacets.selectFacetMethod(field, SimpleFacets.FacetMethod.FC, 1));
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) TrieIntField(org.apache.solr.schema.TrieIntField) Test(org.junit.Test)

Example 80 with SchemaField

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

the class TestFacetMethods method testBooleanDefaults.

@Test
public void testBooleanDefaults() {
    // BoolField defaults to ENUM
    SchemaField field = new SchemaField("field", new BoolField(), 0, null);
    assertEquals(SimpleFacets.FacetMethod.ENUM, SimpleFacets.selectFacetMethod(field, null, 0));
    assertEquals(SimpleFacets.FacetMethod.ENUM, SimpleFacets.selectFacetMethod(field, null, 1));
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) BoolField(org.apache.solr.schema.BoolField) 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