本文整理汇总了Java中org.apache.solr.schema.StrField类的典型用法代码示例。如果您正苦于以下问题:Java StrField类的具体用法?Java StrField怎么用?Java StrField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StrField类属于org.apache.solr.schema包,在下文中一共展示了StrField类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getStringFields
import org.apache.solr.schema.StrField; //导入依赖的package包/类
private ArrayList<String> getStringFields( SolrIndexSearcher searcher ) {
IndexSchema schema = searcher.getSchema();
ArrayList<String> strFields = new ArrayList<String>( );
Collection<String> fieldNames = searcher.getFieldNames();
Iterator<String> fnIt = fieldNames.iterator();
while ( fnIt.hasNext() ) {
String fieldName = fnIt.next( );
if (excludeFields == null || !excludeFields.contains( fieldName )) {
SchemaField field = schema.getField(fieldName);
if (field.stored() && field.getType() instanceof StrField ) {
strFields.add( fieldName );
}
}
}
return strFields;
}
开发者ID:lucidworks,项目名称:query-autofiltering-component,代码行数:19,代码来源:QueryAutoFilteringComponent.java
示例2: getStringFields
import org.apache.solr.schema.StrField; //导入依赖的package包/类
private ArrayList<String> getStringFields( SolrIndexSearcher searcher ) {
IndexSchema schema = searcher.getSchema();
ArrayList<String> strFields = new ArrayList<String>( );
Collection<String> fieldNames = searcher.getFieldNames();
Iterator<String> fnIt = fieldNames.iterator();
while ( fnIt.hasNext() ) {
String fieldName = fnIt.next( );
if (excludeFields == null || !excludeFields.contains( fieldName )) {
try {
SchemaField field = schema.getField(fieldName);
if (field.stored() && field.getType() instanceof StrField ) {
strFields.add( fieldName );
}
}
catch (Throwable e )
{
}
}
}
return strFields;
}
开发者ID:lucidworks,项目名称:query-autofiltering-component,代码行数:25,代码来源:QueryAutoFilteringComponent.java
示例3: getDefaultSelector
import org.apache.solr.schema.StrField; //导入依赖的package包/类
@Override
public FieldMutatingUpdateProcessor.FieldNameSelector
getDefaultSelector(final SolrCore core) {
return new FieldMutatingUpdateProcessor.FieldNameSelector() {
@Override
public boolean shouldMutate(final String fieldName) {
final IndexSchema schema = core.getLatestSchema();
// first check type since it should be fastest
FieldType type = schema.getFieldTypeNoEx(fieldName);
if (null == type) return false;
if (! (TextField.class.isInstance(type)
|| StrField.class.isInstance(type))) {
return false;
}
// only ask for SchemaField if we passed the type check.
SchemaField sf = schema.getFieldOrNull(fieldName);
// shouldn't be null since since type wasn't, but just in case
if (null == sf) return false;
return ! sf.multiValued();
}
};
}
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:ConcatFieldUpdateProcessorFactory.java
示例4: getDefaultSelector
import org.apache.solr.schema.StrField; //导入依赖的package包/类
@Override
public FieldMutatingUpdateProcessor.FieldNameSelector
getDefaultSelector(final SolrCore core) {
final IndexSchema schema = core.getSchema();
return new FieldMutatingUpdateProcessor.FieldNameSelector() {
@Override
public boolean shouldMutate(final String fieldName) {
// first check type since it should be fastest
FieldType type = schema.getFieldTypeNoEx(fieldName);
if (null == type) return false;
if (! (TextField.class.isInstance(type)
|| StrField.class.isInstance(type))) {
return false;
}
// only ask for SchemaField if we passed the type check.
SchemaField sf = schema.getFieldOrNull(fieldName);
// shouldn't be null since since type wasn't, but just in case
if (null == sf) return false;
return ! sf.multiValued();
}
};
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:28,代码来源:ConcatFieldUpdateProcessorFactory.java
示例5: getFieldWriters
import org.apache.solr.schema.StrField; //导入依赖的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;
}
开发者ID:europeana,项目名称:search,代码行数:50,代码来源:SortingResponseWriter.java
示例6: getSortDoc
import org.apache.solr.schema.StrField; //导入依赖的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");
}
}
开发者ID:europeana,项目名称:search,代码行数:64,代码来源:SortingResponseWriter.java
注:本文中的org.apache.solr.schema.StrField类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论