use of edu.harvard.iq.dataverse.search.SolrField in project dataverse by IQSS.
the class DatasetFieldType method getSolrField.
public SolrField getSolrField() {
SolrField.SolrType solrType = SolrField.SolrType.TEXT_EN;
if (fieldType != null) {
/**
* @todo made more decisions based on fieldType: index as dates,
* integers, and floats so we can do range queries etc.
*/
if (fieldType.equals(FieldType.DATE)) {
solrType = SolrField.SolrType.DATE;
} else if (fieldType.equals(FieldType.EMAIL)) {
solrType = SolrField.SolrType.EMAIL;
}
Boolean parentAllowsMultiplesBoolean = false;
if (isHasParent()) {
if (getParentDatasetFieldType() != null) {
DatasetFieldType parent = getParentDatasetFieldType();
parentAllowsMultiplesBoolean = parent.isAllowMultiples();
}
}
boolean makeSolrFieldMultivalued;
// http://stackoverflow.com/questions/5800762/what-is-the-use-of-multivalued-field-type-in-solr
if (allowMultiples || parentAllowsMultiplesBoolean) {
makeSolrFieldMultivalued = true;
} else {
makeSolrFieldMultivalued = false;
}
return new SolrField(name, solrType, makeSolrFieldMultivalued, facetable);
} else {
/**
* @todo: clean this up
*/
String oddValue = name + getTmpNullFieldTypeIdentifier();
boolean makeSolrFieldMultivalued = false;
SolrField solrField = new SolrField(oddValue, solrType, makeSolrFieldMultivalued, facetable);
return solrField;
}
}
use of edu.harvard.iq.dataverse.search.SolrField in project dataverse by IQSS.
the class DatasetFieldTypeTest method testGetSolrField.
@Test
public void testGetSolrField() {
DatasetFieldType instance = new DatasetFieldType();
instance.setFieldType(DatasetFieldType.FieldType.DATE);
SolrField solrField = instance.getSolrField();
assertEquals(SolrField.SolrType.DATE, solrField.getSolrType());
instance.setFieldType(DatasetFieldType.FieldType.EMAIL);
solrField = instance.getSolrField();
assertEquals(SolrField.SolrType.EMAIL, solrField.getSolrType());
DatasetFieldType parent = new DatasetFieldType();
parent.setAllowMultiples(true);
instance.setParentDatasetFieldType(parent);
solrField = instance.getSolrField();
assertEquals(true, solrField.isAllowedToBeMultivalued());
}