本文整理汇总了Java中org.apache.lucene.document.Fieldable类的典型用法代码示例。如果您正苦于以下问题:Java Fieldable类的具体用法?Java Fieldable怎么用?Java Fieldable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Fieldable类属于org.apache.lucene.document包,在下文中一共展示了Fieldable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isLocal
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
public static boolean isLocal(@NonNull final Document doc) {
Fieldable fld = doc.getFieldable(FIELD_BINARY_NAME);
if (fld == null) {
return false;
} else {
final String binName = fld.stringValue();
switch (binName.charAt(binName.length()-1)) {
case EK_LOCAL_ANNOTATION:
case EK_LOCAL_CLASS:
case EK_LOCAL_ENUM:
case EK_LOCAL_INTERFACE:
return true;
default:
return false;
}
}
}
示例2: toResult
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
public SearchItem toResult(int documentId) throws IOException
{
Document document = searcher.doc(documentId);
String type = document.getFieldable(FieldNames.TYPE).stringValue();
NumericField date = (NumericField)document.getFieldable(FieldNames.DATE);
Fieldable path = document.getFieldable(FieldNames.PATH);
NumericField version = (NumericField)document.getFieldable(FieldNames.VERSION);
return new SearchItem
(
Integer.parseInt(type),
path.stringValue(),
(version != null) ? version.getNumericValue().intValue() : -1,
new Date(date.getNumericValue().longValue())
);
}
示例3: getLargestTxIdByCommitTime
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
private long getLargestTxIdByCommitTime(SolrIndexReader reader, Long lastTxCommitTimeBeforeHoles)
throws IOException
{
long txid = -1;
if (lastTxCommitTimeBeforeHoles != -1)
{
TermDocs docs = reader.termDocs(new Term(QueryConstants.FIELD_TXCOMMITTIME, NumericEncoder
.encode(lastTxCommitTimeBeforeHoles)));
while (docs.next())
{
Document doc = reader.document(docs.doc());
Fieldable field = doc.getFieldable(QueryConstants.FIELD_TXID);
if (field != null)
{
long currentTxId = Long.valueOf(field.stringValue());
if (currentTxId > txid)
{
txid = currentTxId;
}
}
}
}
return txid;
}
示例4: getLargestChangeSetIdByCommitTime
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
private long getLargestChangeSetIdByCommitTime(SolrIndexReader reader, Long lastChangeSetCommitTimeBeforeHoles)
throws IOException
{
long txid = -1;
if (lastChangeSetCommitTimeBeforeHoles != -1)
{
TermDocs docs = reader.termDocs(new Term(QueryConstants.FIELD_ACLTXCOMMITTIME, NumericEncoder
.encode(lastChangeSetCommitTimeBeforeHoles)));
while (docs.next())
{
Document doc = reader.document(docs.doc());
Fieldable field = doc.getFieldable(QueryConstants.FIELD_ACLTXID);
if (field != null)
{
long currentTxId = Long.valueOf(field.stringValue());
if (currentTxId > txid)
{
txid = currentTxId;
}
}
}
}
return txid;
}
示例5: makeFieldable
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
/**
* Makes the fieldable to index.
* @param value the value
* @return the fieldable
*/
@Override
protected Fieldable makeFieldable(Object value) {
Double dValue = null;
if (value instanceof Double) {
dValue = (Double)value;
} else if (value instanceof String) {
try {
PropertyValueType valueType = PropertyValueType.DOUBLE;
dValue = (Double)valueType.evaluate((String)value);
} catch (IllegalArgumentException e) {}
}
if (dValue != null) {
boolean bIndex = !this.getIndexingOption().equals(Field.Index.NO);
NumericField fld = new NumericField(this.getName(),this.getStorageOption(),bIndex);
fld.setDoubleValue(dValue);
return fld;
} else {
return null;
}
}
示例6: makeFieldable
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
/**
* Makes the fieldable to index.
* @param value the value
* @return the fieldable
*/
protected Fieldable makeFieldable(Object value) {
Timestamp tsValue = null;
if (value instanceof Timestamp) {
tsValue = (Timestamp)value;
} else if (value instanceof String) {
try {
PropertyValueType valueType = PropertyValueType.TIMESTAMP;
tsValue = (Timestamp)valueType.evaluate((String)value);
} catch (IllegalArgumentException e) {}
}
if (tsValue != null) {
boolean bIndex = !this.getIndexingOption().equals(Field.Index.NO);
NumericField fld = new NumericField(this.getName(),this.getStorageOption(),bIndex);
fld.setLongValue(tsValue.getTime());
return fld;
} else {
return null;
}
}
示例7: makeFieldable
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
/**
* Makes the fieldable to index.
* @param value the value
* @return the fieldable
*/
@Override
protected Fieldable makeFieldable(Object value) {
Long lValue = null;
if (value instanceof Long) {
lValue = (Long)value;
} else if (value instanceof String) {
try {
PropertyValueType valueType = PropertyValueType.LONG;
lValue = (Long)valueType.evaluate((String)value);
} catch (IllegalArgumentException e) {}
}
if (lValue != null) {
boolean bIndex = !this.getIndexingOption().equals(Field.Index.NO);
NumericField fld = new NumericField(this.getName(),this.getStorageOption(),bIndex);
fld.setLongValue(lValue);
return fld;
} else {
return null;
}
}
示例8: removeFromCache
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
private void removeFromCache( long entityId ) throws IOException, CorruptIndexException
{
IndexSearcher searcher = searcher();
Query query = type.idTermQuery( entityId );
TopDocs docs = searcher.search( query, 1 );
if ( docs.totalHits > 0 )
{
Document document = searcher.doc( docs.scoreDocs[0].doc );
for ( Fieldable field : document.getFields() )
{
String key = field.name();
Object value = field.stringValue();
removeFromCache( entityId, key, value );
}
}
}
示例9: getDocumentStoredField
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
@Override
final public LinkedHashMap<String, FieldValue> getDocumentStoredField(final int docId) throws IOException {
LinkedHashMap<String, FieldValue> documentFields = new LinkedHashMap<String, FieldValue>();
Document doc = indexReader.document(docId, FieldSelectors.LoadFieldSelector.INSTANCE);
String currentFieldName = null;
FieldValue currentFieldValue = null;
for (Fieldable field : doc.getFields()) {
if (!field.isStored())
continue;
FieldValue fieldValue = null;
String fieldName = field.name();
if (currentFieldName != null && currentFieldName.equals(fieldName))
fieldValue = currentFieldValue;
else {
fieldValue = documentFields.get(fieldName);
if (fieldValue == null) {
fieldValue = new FieldValue(fieldName);
documentFields.put(fieldName, fieldValue);
}
currentFieldName = fieldName;
currentFieldValue = fieldValue;
}
currentFieldValue.addValue(new FieldValueItem(FieldValueOriginEnum.STORAGE, field.stringValue()));
}
return documentFields;
}
示例10: getValue
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
@Override
public String getValue(String key) {
for (Fieldable field : fields) {
if (field.name().equals(key)) {
return field.stringValue();
}
}
return null;
}
示例11: getValues
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
@Override
public String[] getValues(String key) {
final List<String> result = new ArrayList<String>();
for (Fieldable field : fields) {
if (field.name().equals(key)) {
result.add(field.stringValue());
}
}
return result.toArray(result.isEmpty() ? EMPTY : new String[result.size()]);
}
示例12: getBasicFields
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
public List<Fieldable> getBasicFields()
{
if( basicFields == null )
{
basicFields = standardIndexer.getBasicFields(this);
}
return basicFields;
}
示例13: queryACLEntries
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
public List<Fieldable> queryACLEntries(Object domainObject, String privilege, String prefix)
{
List<Fieldable> fields = new ArrayList<Fieldable>();
List<ACLEntryMapping> allEntriesForObject = aclManager.getAllEntriesForObject(domainObject, privilege);
int i = 0;
for( ACLEntryMapping entry : allEntriesForObject )
{
char grant = entry.getGrant();
boolean all = entry.getExpression().equals(SecurityConstants.getRecipient(Recipient.EVERYONE));
if( all && grant == SecurityConstants.REVOKE )
{
break;
}
fields.add(AbstractIndexingExtension.keyword(prefix + entry.getId(), String.format("%03d%c", i, grant))); //$NON-NLS-1$
if( all )
{
break;
}
i++;
}
return fields;
}
示例14: indexFast
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
@Override
public void indexFast(IndexedItem indexedItem)
{
Item item = indexedItem.getItem();
List<ActivateRequest> activateRequests = activationService.getAllRequests(item);
Document itemdoc = indexedItem.getItemdoc();
List<Fieldable> basicFields = indexedItem.getBasicFields();
List<Document> activationDocs = indexedItem.getDocumentsForIndex(ActivationConstants.ACTIVATION_INDEX_ID);
for( ActivateRequest request : activateRequests )
{
if( request.getCourse() != null )
{
itemdoc.add(keyword(FreeTextQuery.FIELD_COURSE_ID, request.getCourse().getUuid()));
Document doc = new Document();
addAllFields(doc, basicFields);
doc.add(keyword(FreeTextQuery.FIELD_COURSE_ID, request.getCourse().getUuid()));
doc.add(keyword(FreeTextQuery.FIELD_ACTIVATION_ID, Long.toString(request.getId())));
doc.add(keyword(FreeTextQuery.FIELD_ACTIVATION_STATUS, String.valueOf(request.getStatus())));
doc.add(indexed(FreeTextQuery.FIELD_OWNER, request.getUser()));
doc.removeField(FreeTextQuery.FIELD_REALLASTMODIFIED);
doc.add(keyword(FreeTextQuery.FIELD_REALLASTMODIFIED, new UtcDate(request.getTime()).format(Dates.ISO)));
doc.add(indexed(FreeTextQuery.FIELD_ACTIVATION_FROM, new UtcDate(request.getFrom()).format(Dates.ISO)));
doc.add(indexed(FreeTextQuery.FIELD_ACTIVATION_UNTIL, new UtcDate(request.getUntil()).format(Dates.ISO)));
addAllFields(doc, indexedItem.getACLEntries(ActivationConstants.VIEW_ACTIVATION_ITEM));
activationDocs.add(doc);
}
}
}
示例15: addAllFields
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
public void addAllFields(Document doc, List<Fieldable> fields)
{
for( Fieldable field : fields )
{
doc.add(field);
}
}