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


Java SchemaField.indexed方法代码示例

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


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

示例1: getFieldQuery

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
protected Query getFieldQuery(String field, String queryText, boolean quoted) throws SyntaxError {
  checkNullField(field);
  // intercept magic field name of "_" to use as a hook for our
  // own functions.
  if (field.charAt(0) == '_' && parser != null) {
    MagicFieldName magic = MagicFieldName.get(field);
    if (null != magic) {
      subQParser = parser.subQuery(queryText, magic.subParser);
      return subQParser.getQuery();
    }
  }
  SchemaField sf = schema.getFieldOrNull(field);
  if (sf != null) {
    FieldType ft = sf.getType();
    // delegate to type for everything except tokenized fields
    if (ft.isTokenized() && sf.indexed()) {
      return newFieldQuery(getAnalyzer(), field, queryText, quoted || (ft instanceof TextField && ((TextField)ft).getAutoGeneratePhraseQueries()));
    } else {
      return sf.getType().getFieldQuery(parser, sf, queryText);
    }
  }

  // default to a normal field query
  return newFieldQuery(getAnalyzer(), field, queryText, quoted);
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:SolrQueryParserBase.java

示例2: inform

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
@Override
public void inform(SolrCore core) {
  final SchemaField field = core.getLatestSchema().getFieldOrNull(getSignatureField());
  if (null == field) {
    throw new SolrException
      (ErrorCode.SERVER_ERROR,
       "Can't use signatureField which does not exist in schema: "
       + getSignatureField());
  }

  if (getOverwriteDupes() && ( ! field.indexed() ) ) {
    throw new SolrException
      (ErrorCode.SERVER_ERROR,
       "Can't set overwriteDupes when signatureField is not indexed: "
       + getSignatureField());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:SignatureUpdateProcessorFactory.java

示例3: 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

示例4: 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

示例5: selectFacetMethod

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
/**
 * This method will force the appropriate facet method even if the user provided a different one as a request parameter
 *
 * N.B. this method could overwrite what you passed as request parameter. Be Extra careful
 *
 * @param field field we are faceting
 * @param method the facet method passed as a request parameter
 * @param mincount the minimum value a facet should have to be returned
 * @return the FacetMethod to use
 */
 static FacetMethod selectFacetMethod(SchemaField field, FacetMethod method, Integer mincount) {

   FieldType type = field.getType();
   if (type.isPointField()) {
     // Only FCS is supported for PointFields for now
     return FacetMethod.FCS;
   }

   /*The user did not specify any preference*/
   if (method == null) {
     /* Always use filters for booleans if not DocValues only... we know the number of values is very small. */
     if (type instanceof BoolField && (field.indexed() == true || field.hasDocValues() == false)) {
       method = FacetMethod.ENUM;
     } else if (type.getNumberType() != null && !field.multiValued()) {
      /* the per-segment approach is optimal for numeric field types since there
         are no global ords to merge and no need to create an expensive
         top-level reader */
       method = FacetMethod.FCS;
     } else {
       // TODO: default to per-segment or not?
       method = FacetMethod.FC;
     }
   }

   /* FC without docValues does not support single valued numeric facets */
   if (method == FacetMethod.FC
       && type.getNumberType() != null && !field.multiValued()) {
     method = FacetMethod.FCS;
   }

   /* UIF without DocValues can't deal with mincount=0, the reason is because
       we create the buckets based on the values present in the result set.
       So we are not going to see facet values which are not in the result set */
   if (method == FacetMethod.UIF
       && !field.hasDocValues() && mincount == 0) {
     method = field.multiValued() ? FacetMethod.FC : FacetMethod.FCS;
   }

   /* ENUM can't deal with trie fields that index several terms per value */
   if (method == FacetMethod.ENUM
       && TrieField.getMainValuePrefix(type) != null) {
     method = field.multiValued() ? FacetMethod.FC : FacetMethod.FCS;
   }

   /* FCS can't deal with multi token fields */
   final boolean multiToken = field.multiValued() || type.multiValuedFieldCache();
   if (method == FacetMethod.FCS
       && multiToken) {
     method = FacetMethod.FC;
   }

   return method;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:64,代码来源:SimpleFacets.java

示例6: getIndexedFieldsInfo

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
private static SimpleOrderedMap<Object> getIndexedFieldsInfo(SolrQueryRequest req)
    throws Exception {

  SolrIndexSearcher searcher = req.getSearcher();
  SolrParams params = req.getParams();

  Set<String> fields = null;
  String fl = params.get(CommonParams.FL);
  if (fl != null) {
    fields = new TreeSet<>(Arrays.asList(fl.split( "[,\\s]+" )));
  }

  AtomicReader reader = searcher.getAtomicReader();
  IndexSchema schema = searcher.getSchema();

  // Don't be tempted to put this in the loop below, the whole point here is to alphabetize the fields!
  Set<String> fieldNames = new TreeSet<>();
  for(FieldInfo fieldInfo : reader.getFieldInfos()) {
    fieldNames.add(fieldInfo.name);
  }

  // Walk the term enum and keep a priority queue for each map in our set
  SimpleOrderedMap<Object> finfo = new SimpleOrderedMap<>();

  for (String fieldName : fieldNames) {
    if (fields != null && ! fields.contains(fieldName) && ! fields.contains("*")) {
      continue; //we're not interested in this field Still an issue here
    }

    SimpleOrderedMap<Object> fieldMap = new SimpleOrderedMap<>();

    SchemaField sfield = schema.getFieldOrNull( fieldName );
    FieldType ftype = (sfield==null)?null:sfield.getType();

    fieldMap.add( "type", (ftype==null)?null:ftype.getTypeName() );
    fieldMap.add("schema", getFieldFlags(sfield));
    if (sfield != null && schema.isDynamicField(sfield.getName()) && schema.getDynamicPattern(sfield.getName()) != null) {
      fieldMap.add("dynamicBase", schema.getDynamicPattern(sfield.getName()));
    }
    Terms terms = reader.fields().terms(fieldName);
    if (terms == null) { // Not indexed, so we need to report what we can (it made it through the fl param if specified)
      finfo.add( fieldName, fieldMap );
      continue;
    }

    if(sfield != null && sfield.indexed() ) {
      // In the pre-4.0 days, this did a veeeery expensive range query. But we can be much faster now,
      // so just do this all the time.
      Document doc = getFirstLiveDoc(terms, reader);


      if( doc != null ) {
        // Found a document with this field
        try {
          IndexableField fld = doc.getField( fieldName );
          if( fld != null ) {
            fieldMap.add("index", getFieldFlags(fld));
          }
          else {
            // it is a non-stored field...
            fieldMap.add("index", "(unstored field)");
          }
        }
        catch( Exception ex ) {
          log.warn( "error reading field: "+fieldName );
        }
      }
      fieldMap.add("docs", terms.getDocCount());

    }
    if (fields != null && (fields.contains(fieldName) || fields.contains("*"))) {
      getDetailedFieldInfo(req, fieldName, fieldMap);
    }
    // Add the field
    finfo.add( fieldName, fieldMap );
  }
  return finfo;
}
 
开发者ID:europeana,项目名称:search,代码行数:79,代码来源:LukeRequestHandler.java


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