本文整理汇总了Java中org.apache.solr.schema.TrieFloatField类的典型用法代码示例。如果您正苦于以下问题:Java TrieFloatField类的具体用法?Java TrieFloatField怎么用?Java TrieFloatField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TrieFloatField类属于org.apache.solr.schema包,在下文中一共展示了TrieFloatField类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CollapsingFieldValueCollector
import org.apache.solr.schema.TrieFloatField; //导入依赖的package包/类
public CollapsingFieldValueCollector(int maxDoc,
int segments,
SortedDocValues values,
int nullPolicy,
String field,
boolean max,
boolean needsScores,
FieldType fieldType,
IntIntOpenHashMap boostDocs,
FunctionQuery funcQuery, IndexSearcher searcher) throws IOException{
this.maxDoc = maxDoc;
this.contexts = new AtomicReaderContext[segments];
this.values = values;
int valueCount = values.getValueCount();
this.nullPolicy = nullPolicy;
this.needsScores = needsScores;
this.boostDocs = boostDocs;
if(funcQuery != null) {
this.fieldValueCollapse = new ValueSourceCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, funcQuery, searcher, values);
} else {
if(fieldType instanceof TrieIntField) {
this.fieldValueCollapse = new IntValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, values);
} else if(fieldType instanceof TrieLongField) {
this.fieldValueCollapse = new LongValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, values);
} else if(fieldType instanceof TrieFloatField) {
this.fieldValueCollapse = new FloatValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, values);
} else {
throw new IOException("min/max must be either TrieInt, TrieLong or TrieFloat.");
}
}
}
示例2: getSortFieldType
import org.apache.solr.schema.TrieFloatField; //导入依赖的package包/类
private SortField.Type getSortFieldType(SolrCore core, String sortFieldName) {
SortField.Type type = null;
String fieldTypeName = core.getLatestSchema().getField(sortFieldName).getType().getTypeName();
FieldType ft = core.getLatestSchema().getFieldTypes().get(fieldTypeName);
if (ft instanceof FloatField || ft instanceof TrieFloatField) {
type = SortField.Type.FLOAT;
} else if (ft instanceof IntField || ft instanceof TrieIntField) {
type = SortField.Type.INT;
} else if (ft instanceof LongField || ft instanceof TrieLongField) {
type = SortField.Type.LONG;
} else if (ft instanceof DoubleField || ft instanceof TrieDoubleField) {
type = SortField.Type.DOUBLE;
}
return type;
}
示例3: extractQuery
import org.apache.solr.schema.TrieFloatField; //导入依赖的package包/类
private static Query extractQuery(IndexSchema schema, String term, String value) {
String field = term;
if (hasBlockJoinHint(term)) {
field = term.split(BLOCK_JOIN_PATH_HINT)[1];
}
if (field.indexOf(":") > -1) {
String[] keyValue = field.split(":");
field = keyValue[0];
String query = keyValue[1];
return buildQueryFromText(field, schema, query);
} else if (value.matches("^.*:\\[.*\\sTO\\s.*\\]$")) {
return buildQueryFromText(field, schema, value);
} else if (null != tryParseDate(value)) {
if (schema.getField(field).getType() instanceof TrieDateField) {
return new TrieDateField().getFieldQuery(null, schema.getField(field), value);
}
throw new RuntimeException("Can not group on date field not a TrieDateField");
} else if (value.matches("^-{0,1}[0-9]+")) {
// number
FieldType type = schema.getField(field).getType();
NumericType numericType = type.getNumericType();
if (numericType == NumericType.FLOAT) {
return new TrieFloatField().getFieldQuery(null, schema.getField(field), value);
} else if (numericType == NumericType.INT) {
return new TrieIntField().getFieldQuery(null, schema.getField(field), value);
} else if (numericType == NumericType.LONG) {
return new TrieLongField().getFieldQuery(null, schema.getField(field), value);
} else if (numericType == NumericType.DOUBLE) {
return new TrieDoubleField().getFieldQuery(null, schema.getField(field), value);
} else {
return new WildcardQuery(new Term(field, null != value ? value : "*"));
}
} else {
return new WildcardQuery(new Term(field, null != value ? value : "*"));
}
}
示例4: CollapsingFieldValueCollector
import org.apache.solr.schema.TrieFloatField; //导入依赖的package包/类
public CollapsingFieldValueCollector(int maxDoc,
int segments,
SortedDocValues values,
int nullPolicy,
String field,
boolean max,
boolean needsScores,
FieldType fieldType,
IntOpenHashSet boostDocs,
FunctionQuery funcQuery, IndexSearcher searcher) throws IOException{
this.maxDoc = maxDoc;
this.contexts = new AtomicReaderContext[segments];
this.values = values;
int valueCount = values.getValueCount();
this.nullPolicy = nullPolicy;
this.needsScores = needsScores;
this.boostDocs = boostDocs;
if(funcQuery != null) {
this.fieldValueCollapse = new ValueSourceCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs, funcQuery, searcher);
} else {
if(fieldType instanceof TrieIntField) {
this.fieldValueCollapse = new IntValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs);
} else if(fieldType instanceof TrieLongField) {
this.fieldValueCollapse = new LongValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs);
} else if(fieldType instanceof TrieFloatField) {
this.fieldValueCollapse = new FloatValueCollapse(maxDoc, field, nullPolicy, new int[valueCount], max, this.needsScores, boostDocs);
} else {
throw new IOException("min/max must be either TrieInt, TrieLong or TrieFloat.");
}
}
}
示例5: getFieldWriters
import org.apache.solr.schema.TrieFloatField; //导入依赖的package包/类
protected FieldWriter[] getFieldWriters(String[] fields, SolrIndexSearcher searcher) throws IOException {
IndexSchema schema = searcher.getSchema();
FieldWriter[] writers = new FieldWriter[fields.length];
for(int i=0; i<fields.length; i++) {
String field = fields[i];
SchemaField schemaField = schema.getField(field);
if(!schemaField.hasDocValues()) {
throw new IOException(field+" must have DocValues to use this feature.");
}
boolean multiValued = schemaField.multiValued();
FieldType fieldType = schemaField.getType();
if(fieldType instanceof TrieIntField) {
if(multiValued) {
writers[i] = new MultiFieldWriter(field, fieldType, true);
} else {
writers[i] = new IntFieldWriter(field);
}
} else if (fieldType instanceof TrieLongField) {
if(multiValued) {
writers[i] = new MultiFieldWriter(field, fieldType, true);
} else {
writers[i] = new LongFieldWriter(field);
}
} else if (fieldType instanceof TrieFloatField) {
if(multiValued) {
writers[i] = new MultiFieldWriter(field, fieldType, true);
} else {
writers[i] = new FloatFieldWriter(field);
}
} else if(fieldType instanceof TrieDoubleField) {
if(multiValued) {
writers[i] = new MultiFieldWriter(field, fieldType, true);
} else {
writers[i] = new DoubleFieldWriter(field);
}
} else if(fieldType instanceof StrField) {
if(multiValued) {
writers[i] = new MultiFieldWriter(field, fieldType, false);
} else {
writers[i] = new StringFieldWriter(field, fieldType);
}
} else {
throw new IOException("Export fields must either be one of the following types: int,float,long,double,string");
}
}
return writers;
}
示例6: getSortDoc
import org.apache.solr.schema.TrieFloatField; //导入依赖的package包/类
private SortDoc getSortDoc(SolrIndexSearcher searcher, SortField[] sortFields) throws IOException {
SortValue[] sortValues = new SortValue[sortFields.length];
IndexSchema schema = searcher.getSchema();
for(int i=0; i<sortFields.length; ++i) {
SortField sf = sortFields[i];
String field = sf.getField();
boolean reverse = sf.getReverse();
SchemaField schemaField = schema.getField(field);
FieldType ft = schemaField.getType();
if(!schemaField.hasDocValues()) {
throw new IOException(field+" must have DocValues to use this feature.");
}
if(ft instanceof TrieIntField) {
if(reverse) {
sortValues[i] = new IntValue(field, new IntDesc());
} else {
sortValues[i] = new IntValue(field, new IntAsc());
}
} else if(ft instanceof TrieFloatField) {
if(reverse) {
sortValues[i] = new FloatValue(field, new FloatDesc());
} else {
sortValues[i] = new FloatValue(field, new FloatAsc());
}
} else if(ft instanceof TrieDoubleField) {
if(reverse) {
sortValues[i] = new DoubleValue(field, new DoubleDesc());
} else {
sortValues[i] = new DoubleValue(field, new DoubleAsc());
}
} else if(ft instanceof TrieLongField) {
if(reverse) {
sortValues[i] = new LongValue(field, new LongDesc());
} else {
sortValues[i] = new LongValue(field, new LongAsc());
}
} else if(ft instanceof StrField) {
AtomicReader reader = searcher.getAtomicReader();
SortedDocValues vals = reader.getSortedDocValues(field);
if(reverse) {
sortValues[i] = new StringValue(vals, field, new IntDesc());
} else {
sortValues[i] = new StringValue(vals, field, new IntAsc());
}
} else {
throw new IOException("Sort fields must be one of the following types: int,float,long,double,string");
}
}
if(sortValues.length == 1) {
return new SingleValueSortDoc(sortValues[0]);
} else if(sortValues.length == 2) {
return new DoubleValueSortDoc(sortValues[0], sortValues[1]);
} else if(sortValues.length == 3) {
return new TripleValueSortDoc(sortValues[0], sortValues[1], sortValues[2]);
} else if(sortValues.length == 4) {
return new QuadValueSortDoc(sortValues[0], sortValues[1], sortValues[2], sortValues[3]);
} else {
throw new IOException("A max of 4 sorts can be specified");
}
}