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


Java SchemaField.getName方法代码示例

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


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

示例1: GenerateSolrSequenceKey

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
public GenerateSolrSequenceKey(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
  super(builder, config, parent, child, context);
  this.baseIdFieldName = getConfigs().getString(config, "baseIdField", Fields.BASE_ID);
  this.preserveExisting = getConfigs().getBoolean(config, "preserveExisting", true);      
  
  Config solrLocatorConfig = getConfigs().getConfig(config, "solrLocator");
  SolrLocator locator = new SolrLocator(solrLocatorConfig, context);
  LOG.debug("solrLocator: {}", locator);
  IndexSchema schema = locator.getIndexSchema();
  SchemaField uniqueKey = schema.getUniqueKeyField();
  uniqueKeyName = uniqueKey == null ? null : uniqueKey.getName();
  
  String tmpIdPrefix = getConfigs().getString(config, "idPrefix", null);  // for load testing only
  Random tmpRandomIdPrefx = null;
  if ("random".equals(tmpIdPrefix)) { // for load testing only
    tmpRandomIdPrefx = new Random(new SecureRandom().nextLong());    
    tmpIdPrefix = null;
  }
  idPrefix = tmpIdPrefix;
  randomIdPrefix = tmpRandomIdPrefx;
  validateArguments();
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:GenerateSolrSequenceKeyBuilder.java

示例2: getIndexedId

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
/** Returns the indexed ID for this document.  The returned BytesRef is retained across multiple calls, and should not be modified. */
public BytesRef getIndexedId() {
  if (indexedId == null) {
    IndexSchema schema = req.getSchema();
    SchemaField sf = schema.getUniqueKeyField();
    if (sf != null) {
      if (solrDoc != null) {
        SolrInputField field = solrDoc.getField(sf.getName());

        int count = field==null ? 0 : field.getValueCount();
        if (count == 0) {
          if (overwrite) {
            throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document is missing mandatory uniqueKey field: " + sf.getName());
          }
        } else if (count  > 1) {
          throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document contains multiple values for uniqueKey field: " + field);
        } else {
          BytesRef b = new BytesRef();
          sf.getType().readableToIndexed(field.getFirstValue().toString(), b);
          indexedId = b;
        }
      }
    }
  }
  return indexedId;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:AddUpdateCommand.java

示例3: getHashableId

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
/**
 * @return String id to hash
 */
public String getHashableId() {
  String id = null;
  IndexSchema schema = req.getSchema();
  SchemaField sf = schema.getUniqueKeyField();
  if (sf != null) {
    if (solrDoc != null) {
      SolrInputField field = solrDoc.getField(sf.getName());
      
      int count = field == null ? 0 : field.getValueCount();
      if (count == 0) {
        if (overwrite) {
          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
              "Document is missing mandatory uniqueKey field: "
                  + sf.getName());
        }
      } else if (count > 1) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
            "Document contains multiple values for uniqueKey field: " + field);
      } else {
        return field.getFirstValue().toString();
      }
    }
  }
  return id;
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:AddUpdateCommand.java

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

示例5: LocalDocEnv

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
public LocalDocEnv(int offset, int limit, int startTermIndex, int adjust, int targetIdx, String targetDoc, int nTerms,
    Predicate<BytesRef> termFilter, int mincount, int[] counts, CharsRefBuilder charsRef, boolean extend,
    SortedSetDocValues si, SolrIndexSearcher searcher, DocSet docs, List<Entry<LeafReader, Bits>> leaves, String fieldName, T ft, NamedList res, Set<String> fl) {
  super(offset, limit, startTermIndex, adjust, targetIdx, nTerms, termFilter, mincount, counts,
      charsRef, extend, si, searcher, leaves, fieldName, ft, res);
  SchemaField uniqueKeyField = searcher.getSchema().getUniqueKeyField();
  this.targetDoc = new BytesRef(targetDoc);
  this.idField = uniqueKeyField.getName();
  this.sortField = uniqueKeyField.getSortField(false);
  this.idFieldComparator = this.sortField.getBytesComparator();
  this.sort = new Sort(sortField);
  this.docs = docs;
  this.fl = fl;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:15,代码来源:DocBasedFacetResponseBuilder.java

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

示例7: getInstance

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
                                          SolrQueryResponse rsp,
                                          UpdateRequestProcessor next ) {
  if (StringUtils.isEmpty(fieldName)) {
    SchemaField schemaField = req.getSchema().getUniqueKeyField();
    fieldName = schemaField.getName();
  }

  return new AbstractDefaultValueUpdateProcessorFactory.DefaultValueUpdateProcessor(fieldName, next) {
    @Override
    public Object getDefaultValue() {
      return UUID.randomUUID().toString().toLowerCase(Locale.ROOT);
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:UUIDUpdateProcessorFactory.java

示例8: processAdd

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  String text = null;
  try {
    /* get Solr document */
    SolrInputDocument solrInputDocument = cmd.getSolrInputDocument();

    /* get the fields to analyze */
    String[] texts = getTextsToAnalyze(solrInputDocument);
    for (int i = 0; i < texts.length; i++) {
      text = texts[i];
      if (text != null && text.length()>0) {
        /* create a JCas which contain the text to analyze */
        JCas jcas = pool.getJCas(0);
        try {
          /* process the text value */
          processText(text, jcas);

          UIMAToSolrMapper uimaToSolrMapper = new UIMAToSolrMapper(
              solrInputDocument, jcas);
          /* get field mapping from config */
          Map<String,Map<String,MapField>> typesAndFeaturesFieldsMap = solrUIMAConfiguration
              .getTypesFeaturesFieldsMapping();
          /* map type features on fields */
          for (Entry<String,Map<String,MapField>> entry : typesAndFeaturesFieldsMap
              .entrySet()) {
            uimaToSolrMapper.map(entry.getKey(), entry.getValue());
          }
        } finally {
          pool.releaseJCas(jcas);
        }
      }
    }
  } catch (Exception e) {
    String logField = solrUIMAConfiguration.getLogField();
    if (logField == null) {
      SchemaField uniqueKeyField = cmd.getReq().getSchema()
          .getUniqueKeyField();
      if (uniqueKeyField != null) {
        logField = uniqueKeyField.getName();
      }
    }
    String optionalFieldInfo = logField == null ? "."
        : new StringBuilder(". ")
            .append(logField)
            .append("=")
            .append(
                (String) cmd.getSolrInputDocument().getField(logField)
                    .getValue()).append(", ").toString();
    int len;
    String debugString;
    if (text != null && text.length() > 0) {
      len = Math.min(text.length(), 100);
      debugString = new StringBuilder(" text=\"")
          .append(text.substring(0, len)).append("...\"").toString();
    } else {
      debugString = " null text";
    }
    if (solrUIMAConfiguration.isIgnoreErrors()) {
      log.warn(
          "skip the text processing due to {}",
          new StringBuilder().append(e.getLocalizedMessage())
              .append(optionalFieldInfo).append(debugString));
    } else {
      throw new SolrException(ErrorCode.SERVER_ERROR, new StringBuilder(
          "processing error ").append(e.getLocalizedMessage())
          .append(optionalFieldInfo).append(debugString).toString(), e);
    }
  }
  super.processAdd(cmd);
}
 
开发者ID:europeana,项目名称:search,代码行数:72,代码来源:UIMAUpdateRequestProcessor.java

示例9: create

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
@Override
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
  SchemaField uniqueKeyField = req.getSchema().getUniqueKeyField();
  String idfield = uniqueKeyField.getName();
  return new ExcludedTransformer(field,idfield, uniqueKeyField.getType());
}
 
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:ExcludedMarkerFactory.java

示例10: create

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
@Override
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
  SchemaField uniqueKeyField = req.getSchema().getUniqueKeyField();
  String idfield = uniqueKeyField.getName();
  return new MarkTransformer(field,idfield, uniqueKeyField.getType());
}
 
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:ElevatedMarkerFactory.java

示例11: retrieveDocument

import org.apache.solr.schema.SchemaField; //导入方法依赖的package包/类
private Document retrieveDocument(final SchemaField uniqueField, int doc) throws IOException {
  DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(uniqueField.getName());
  rb.req.getSearcher().doc(doc, visitor);
  return visitor.getDocument();
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:TopGroupsResultTransformer.java


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