本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
};
}
示例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);
}
示例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());
}
示例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());
}
示例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();
}