本文整理汇总了Java中org.apache.lucene.document.Fieldable类的典型用法代码示例。如果您正苦于以下问题:Java Fieldable类的具体用法?Java Fieldable怎么用?Java Fieldable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Fieldable类属于org.apache.lucene.document包,在下文中一共展示了Fieldable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DocumentUtil.java
示例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())
);
}
开发者ID:dcos,项目名称:exhibitor,代码行数:17,代码来源:LogSearch.java
示例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;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:LegacySolrInformationServer.java
示例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;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:LegacySolrInformationServer.java
示例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;
}
}
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:26,代码来源:DoubleField.java
示例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;
}
}
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:25,代码来源:TimestampField.java
示例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;
}
}
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:26,代码来源:LongField.java
示例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 );
}
}
}
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:17,代码来源:LuceneBatchInserterIndex.java
示例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;
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:27,代码来源:ReaderLocal.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ClusteredIndexables.java
示例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()]);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ClusteredIndexables.java
示例12: getBasicFields
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
public List<Fieldable> getBasicFields()
{
if( basicFields == null )
{
basicFields = standardIndexer.getBasicFields(this);
}
return basicFields;
}
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:IndexedItem.java
示例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;
}
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:IndexedItem.java
示例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);
}
}
}
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:ActivationIndexer.java
示例15: addAllFields
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
public void addAllFields(Document doc, List<Fieldable> fields)
{
for( Fieldable field : fields )
{
doc.add(field);
}
}
开发者ID:equella,项目名称:Equella,代码行数:8,代码来源:AbstractIndexingExtension.java
示例16: ensureIndxedFiles
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
private void ensureIndxedFiles() {
if (indexedFiles != null) {
return;
}
indexedFiles = new LinkedHashSet<String>();
for (Fieldable f : doc.getFieldables(INDEXED_FILE_FIELD)) {
String v = f.stringValue();
indexedFiles.add(v);
}
}
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:11,代码来源:PubmedIndexProperties.java
示例17: addWaveFieldsToIndex
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
private void addWaveFieldsToIndex(WaveId waveId, WaveViewData waveData, Document doc) throws WaveletStateException {
WaveDigestWithSupplements digestWithSupplements = digester.generateDigestWithSupplements(waveData);
WaveDigest digest = digestWithSupplements.getDigest();
Map<ParticipantId, WaveDigestSupplement> supplements = digestWithSupplements.getSupplements();
if (digest.getParticipants().size() > 0) {
addField(doc, IndexCondition.Field.WAVE_ID, digest.getWaveId());
addField(doc, IndexCondition.Field.CREATOR, digest.getCreator());
for (String participant : digest.getParticipants()) {
doc.add(new Field(IndexCondition.Field.PARTICIPANTS.toString(), participant, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
}
addField(doc, IndexCondition.Field.TITLE, digest.getTitle());
addField(doc, IndexCondition.Field.CONTENT, digest.getTitle());
addField(doc, IndexCondition.Field.SNIPPET, digest.getSnippet());
addField(doc, IndexCondition.Field.BLIP_COUNT, Integer.toString(digest.getBlipCount()));
for (ReadableWaveletData wavelet : waveData.getWavelets()) {
if (IdUtil.isConversationalId(wavelet.getWaveletId())
|| IdUtil.isConversationalId(wavelet.getWaveletId())) {
for (String tag : wavelet.getTags()) {
addField(doc, IndexCondition.Field.TAG, tag);
addField(doc, IndexCondition.Field.CONTENT, tag);
}
addField(doc, IndexCondition.Field.CONTENT, textCollator.collateTextForWavelet(wavelet));
}
}
addField(doc, IndexCondition.Field.CREATED, Long.toString(digest.getCreated()));
addField(doc, IndexCondition.Field.LAST_MODIFIED, Long.toString(digest.getLastModified()));
for (ParticipantId participantId : supplements.keySet()) {
WaveDigestSupplement supplement = supplements.get(participantId);
addField(doc, IndexCondition.Field.IN_, IndexCondition.Field.IN_.toString() + participantId.getAddress(),
supplement.getFolder());
addField(doc, IndexCondition.Field.UNREAD_COUNT_, IndexCondition.Field.UNREAD_COUNT_.toString() + participantId.getAddress(),
Integer.toString(supplement.getUnreadCount()));
}
LOG.fine("Write index for wave " + waveId.serialise());
for (Fieldable field : doc.getFields()) {
LOG.fine(" " + field.name() + " : " + field.stringValue());
}
}
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:40,代码来源:LuceneSearchImpl.java
示例18: onRecord
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
@Override
protected void onRecord(DiscoveredRecord record, Document document) {
Map<String, List<String>> fieldMap = new HashMap<String, List<String>>();
for (Fieldable field : document.getFields()) {
String name = field.name();
List<String> fieldValues = fieldMap.get(name);
if (fieldValues == null) {
fieldValues = new ArrayList<String>();
fieldMap.put(name, fieldValues);
}
fieldValues.add(field.stringValue());
}
mapping.put(record, fieldMap);
}
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:15,代码来源:DcatJsonSearchEngine.java
示例19: appendForWrite
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
/**
* Appends the field to a document prior to writing the document to the index.
* <p/>
* The field will not be appended if it's name or value is empty.
* @param document the Lucene document
* @param value the input value to write
*/
protected void appendForWrite(Document document, Object value) {
String sName = getName();
Fieldable fld = null;
String sValueInput = null;
if (value != null) {
sValueInput = value.toString();
fld = this.makeFieldable(value);
}
if (sName.length() == 0) {
LOGGER.fine("The field has not been named and will not be stored.");
} else if (fld == null) {
LOGGER.log(Level.FINER, "{0} has an empty value and will not be stored.", sName);
} else {
if (fld != null) {
if (LOGGER.isLoggable(Level.FINER)) {
String sTmp = fld.stringValue();
if (sTmp.length() > 101) sTmp = sTmp.substring(0,101)+" ...";
StringBuilder sb = new StringBuilder();
sb.append("Appending field:\n ");
sb.append(" name=\"").append(fld.name()).append("\"");
sb.append(" stored=\"").append(fld.isStored()).append("\"");
sb.append(" indexed=\"").append(fld.isIndexed()).append("\"");
sb.append(" analyzed=\"").append(fld.isTokenized()).append("\"");
sb.append(" termVector=\"").append(fld.isTermVectorStored()).append("\"");
sb.append("\n storeValue=\"").append(sTmp).append("\"");
if ((sValueInput != null) && !sValueInput.equals(fld.stringValue())) {
sTmp = sValueInput;
if (sTmp.length() > 101) sTmp = sTmp.substring(0,101)+" ...";
sb.append("\n inputValue=\"").append(sValueInput).append("\"");
}
LOGGER.finer(sb.toString());
}
document.add(fld);
}
}
}
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:45,代码来源:DatastoreField.java
示例20: makeFieldable
import org.apache.lucene.document.Fieldable; //导入依赖的package包/类
/**
* Makes the fieldable to index.
* <p/>
* Sub-classes should override this method if converted values need to
* be written for subsequent search (ex. Doubles, Longs, Timestamps ...).
* <p/>
* The default behavior is to return the supplied value.
* <br/>Null or empty values will not be stored.
* @param value the value
* @return the fieldable
*/
protected Fieldable makeFieldable(Object value) {
if ((value != null) && (value instanceof String)) {
String sValue = (String)value;
if (sValue.length() > 0) {
Field.Store storage = getStorageOption();
Field.Index indexing = getIndexingOption();
Field.TermVector termVector = getTermVectorOption();
return new Field(this.getName(),sValue,storage,indexing,termVector);
}
}
return null;
}
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:24,代码来源:DatastoreField.java
注:本文中的org.apache.lucene.document.Fieldable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论