当前位置: 首页>>代码示例>>Java>>正文


Java SchemaField.stored方法代码示例

本文整理汇总了Java中org.apache.solr.schema.SchemaField.stored方法的典型用法代码示例。如果您正苦于以下问题:Java SchemaField.stored方法的具体用法?Java SchemaField.stored怎么用?Java SchemaField.stored使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.schema.SchemaField的用法示例。


在下文中一共展示了SchemaField.stored方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStringFields

import org.apache.solr.schema.SchemaField; //导入方法依赖的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.SchemaField; //导入方法依赖的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: inform

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
@Override
public void inform(SolrCore core) {

  if (core.getUpdateHandler().getUpdateLog() == null) {
    throw new SolrException(SERVER_ERROR,
        "updateLog must be enabled.");
  }

  if (core.getLatestSchema().getUniqueKeyField() == null) {
    throw new SolrException(SERVER_ERROR,
        "schema must have uniqueKey defined.");
  }

  SchemaField userVersionField = core.getLatestSchema().getField(versionField);
  if (userVersionField == null || !userVersionField.stored() || userVersionField.multiValued()) {
    throw new SolrException(SERVER_ERROR,
        "field " + versionField + " must be defined in schema, be stored, and be single valued.");
  }

  try {
    ValueSource vs = userVersionField.getType().getValueSource(userVersionField, null);
    useFieldCache = true;
  } catch (Exception e) {
    log.warn("Can't use fieldcache/valuesource: " + e.getMessage());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:DocBasedVersionConstraintsProcessorFactory.java

示例4: getStoredHighlightFieldNames

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
/**
 * Returns a collection of the names of all stored fields which can be
 * highlighted the index reader knows about.
 */
public Collection<String> getStoredHighlightFieldNames() {
  synchronized (this) {
    if (storedHighlightFieldNames == null) {
      storedHighlightFieldNames = new LinkedList<>();
      for (String fieldName : fieldNames) {
        try {
          SchemaField field = schema.getField(fieldName);
          if (field.stored() &&
              ((field.getType() instanceof org.apache.solr.schema.TextField) ||
                  (field.getType() instanceof org.apache.solr.schema.StrField))) {
            storedHighlightFieldNames.add(fieldName);
          }
        } catch (RuntimeException e) { // getField() throws a SolrException, but it arrives as a RuntimeException
          log.warn("Field \"" + fieldName + "\" found in index, but not defined in schema.");
        }
      }
    }
    return storedHighlightFieldNames;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:SolrIndexSearcher.java

示例5: toSolrInputDocument

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
private static SolrInputDocument toSolrInputDocument(Document doc, IndexSchema schema) {
  SolrInputDocument out = new SolrInputDocument();
  for( IndexableField f : doc.getFields() ) {
    String fname = f.name();
    SchemaField sf = schema.getFieldOrNull(f.name());
    Object val = null;
    if (sf != null) {
      if (!sf.stored() || schema.isCopyFieldTarget(sf)) continue;
      val = sf.getType().toObject(f);   // object or external string?
    } else {
      val = f.stringValue();
      if (val == null) val = f.numericValue();
      if (val == null) val = f.binaryValue();
      if (val == null) val = f;
    }

    // todo: how to handle targets of copy fields (including polyfield sub-fields)?
    out.addField(fname, val);
  }
  return out;
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:RealTimeGetComponent.java

示例6: handleIndexableField

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
private IndexableField handleIndexableField(SchemaField field, String source, String target, float boost) {
    if (StringUtils.isEmpty(source) || StringUtils.isEmpty(target)) {
        return null;
    }
    FieldType fieldType = PreAnalyzedField.createFieldType(field);
    if (null == fieldType) {
        return null;
    }
    Field indexableField = null;
    if (field.stored()) {
        indexableField = new Field(field.getName(), target, fieldType);
    }
    if (field.indexed()) {
        TokenStream tokenStream = ((MultiLangAnalyzer) this.getAnalyzer()).createComponents(field.getName(),
                new StringReader(source)).getTokenStream();
        if (null != indexableField) {
            indexableField.setTokenStream(tokenStream);
        } else {
            indexableField = new Field(field.getName(), tokenStream, fieldType);
        }
    }
    if (null != indexableField) {
        indexableField.setBoost(boost);
    }
    return indexableField;
}
 
开发者ID:smalldirector,项目名称:solr-multilingual-analyzer,代码行数:27,代码来源:MultiLangField.java

示例7: createField

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
@Override
    public IndexableField createField(SchemaField field, Object val, float boost) {
        if (val == null) return null;
        if (!field.stored()) {
            return null;
        }
        byte[] buf = null;
        int offset = 0, len = 0;
        if (val instanceof byte[]) {
            buf = (byte[]) val;
            len = buf.length;
        } else if (val instanceof ByteBuffer && ((ByteBuffer)val).hasArray()) {
            ByteBuffer byteBuf = (ByteBuffer) val;
            buf = byteBuf.array();
            offset = byteBuf.position();
            len = byteBuf.limit() - byteBuf.position();
        } else {
            String strVal = val.toString();
            //the string has to be a base64 encoded string
            buf = Base64.base64ToByteArray(strVal);
            offset = 0;
            len = buf.length;
        }

        Field f = new org.apache.lucene.document.BinaryDocValuesField(field.getName(), new BytesRef(buf, offset, len));
//        Field f = new org.apache.lucene.document.StoredField(field.getName(), buf, offset, len);
        f.setBoost(boost);
        return f;
    }
 
开发者ID:dermotte,项目名称:liresolr,代码行数:30,代码来源:BinaryDocValuesField.java

示例8: getAndCheckVersionField

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
/**
 * Gets and returns the {@link #VERSION_FIELD} from the specified 
 * schema, after verifying that it is indexed, stored, and single-valued.  
 * If any of these pre-conditions are not met, it throws a SolrException 
 * with a user suitable message indicating the problem.
 */
public static SchemaField getAndCheckVersionField(IndexSchema schema) 
  throws SolrException {
  final String errPrefix = VERSION_FIELD + " field must exist in schema, using indexed=\"true\" or docValues=\"true\", stored=\"true\" and multiValued=\"false\"";
  SchemaField sf = schema.getFieldOrNull(VERSION_FIELD);

  if (null == sf) {
    throw new SolrException
      (SolrException.ErrorCode.SERVER_ERROR, 
       errPrefix + " (" + VERSION_FIELD + " does not exist)");
  }
  if ( !sf.indexed() && !sf.hasDocValues()) {
    throw new SolrException
      (SolrException.ErrorCode.SERVER_ERROR, 
       errPrefix + " (" + VERSION_FIELD + " must be either indexed or have docValues");
  }
  if ( !sf.stored() ) {
    throw new SolrException
      (SolrException.ErrorCode.SERVER_ERROR, 
       errPrefix + " (" + VERSION_FIELD + " is not stored");
  }
  if ( sf.multiValued() ) {
    throw new SolrException
      (SolrException.ErrorCode.SERVER_ERROR, 
       errPrefix + " (" + VERSION_FIELD + " is multiValued");
  }
  
  return sf;
}
 
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:VersionInfo.java


注:本文中的org.apache.solr.schema.SchemaField.stored方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。