Methods Summary |
---|
public void | addSchemaField(IndexSchemaField field)Adds a new {@link IndexSchemaField} to the schema. if the fields name
equals {@link IndexDocument#FIELD_ENTRY_ID} or the field is
null it will simply ignored
if (field == null)
return;
/*
* skip fields configured in the gdata-config.xml file if their names
* match a primary key field id of the IndexDocument
*/
if (field.getName().equals(IndexDocument.FIELD_ENTRY_ID)
|| field.getName().equals(IndexDocument.FIELD_FEED_ID))
return;
if (field.getAnalyzerClass() != null) {
/*
* enable per field analyzer if one is set.
*/
Analyzer analyzer = getAnalyzerInstance(field.getAnalyzerClass());
/*
* null values will be omitted here
*/
buildPerFieldAnalyzerWrapper(analyzer, field.getName());
}
this.schemaFields.add(field);
this.searchableFieldNames.add(field.getName());
|
private void | buildPerFieldAnalyzerWrapper(org.apache.lucene.analysis.Analyzer anazlyer, java.lang.String field)
if (anazlyer == null || field == null || field.length() == 0)
return;
if (this.perFieldAnalyzer == null)
this.perFieldAnalyzer = new PerFieldAnalyzerWrapper(
this.serviceAnalyzer);
this.perFieldAnalyzer.addAnalyzer(field, anazlyer);
|
public boolean | equals(java.lang.Object object)
if (this == object)
return true;
if (object == null)
return false;
if (object instanceof IndexSchema) {
if(this.name ==null)
return super.equals(object);
return this.name.equals(((IndexSchema) object).getName());
}
return false;
|
private static org.apache.lucene.analysis.Analyzer | getAnalyzerInstance(java.lang.Class clazz)
if (!ReflectionUtils.extendsType(clazz, Analyzer.class)) {
LOG.warn("Can not create analyzer for class " + clazz.getName());
return null;
}
try {
return clazz.newInstance();
} catch (Exception e) {
LOG.warn("Can not create analyzer for class " + clazz.getName());
}
return null;
|
public int | getCommitAfterDocuments()Defines after how many added,removed or updated document the indexer should commit.
return this.commitAfterDocuments;
|
public long | getCommitLockTimeout()
return this.commitLockTimeout;
|
public java.lang.String | getDefaultSearchField()
return this.defaultSearchField;
|
public java.util.Collection | getFields()
return this.schemaFields;
|
public java.lang.String | getIndexLocation()
return this.indexLocation;
|
public long | getIndexerIdleTime()
return this.indexerIdleTime;
|
public int | getMaxBufferedDocs()
return this.maxBufferedDocs;
|
public int | getMaxFieldLength()
return this.maxFieldLength;
|
public int | getMaxMergeDocs()
return this.maxMergeDocs;
|
public int | getMergeFactor()
return this.mergeFactor;
|
public java.lang.String | getName()
return this.name;
|
public int | getOptimizeAfterCommit()Defines after how many commits the indexer should optimize the index
return this.optimizeAfterCommit;
|
public org.apache.lucene.analysis.Analyzer | getSchemaAnalyzer()
if (this.perFieldAnalyzer == null)
return this.serviceAnalyzer;
return this.perFieldAnalyzer;
|
public java.util.Set | getSearchableFieldNames()
return this.searchableFieldNames;
|
public org.apache.lucene.analysis.Analyzer | getServiceAnalyzer()
return this.serviceAnalyzer;
|
public long | getWriteLockTimeout()
return this.writeLockTimeout;
|
public int | hashCode()
if (this.name == null)
return super.hashCode();
return this.name.hashCode();
|
public void | initialize()Initialize the schema and checks all required values
for (IndexSchemaField field : this.schemaFields) {
if (!field.checkRequieredValues())
throw new RuntimeException("Required Value for field: "
+ field.getName() + " is missing");
}
if (this.defaultSearchField == null)
throw new RuntimeException("DefaulSearchField must not be null");
if (this.name == null)
throw new RuntimeException(
"Schema field is not set -- must not be null");
if (this.indexLocation == null)
throw new RuntimeException("IndexLocation must not be null");
if(!this.searchableFieldNames.contains(this.defaultSearchField)){
throw new RuntimeException("the default search field: "+this.defaultSearchField+" is registered as a field");
}
|
public boolean | isUseCompoundFile()
return this.useCompoundFile;
|
public boolean | isUseTimedIndexer()
return this.useTimedIndexer;
|
public void | setCommitAfterDocuments(int commitAfterDocuments)
if(commitAfterDocuments < DEFAULT_COMMIT_COUNT)
return;
this.commitAfterDocuments = commitAfterDocuments;
|
public void | setCommitLockTimeout(long commitLockTimeout)
// TODO enable this in config
this.commitLockTimeout = commitLockTimeout;
|
public void | setDefaultSearchField(java.lang.String defaultField)
this.defaultSearchField = defaultField;
|
public void | setIndexLocation(java.lang.String indexLocation)
this.indexLocation = indexLocation;
|
public void | setIndexerIdleTime(long indexerIdleTime)
this.indexerIdleTime = indexerIdleTime;
|
public void | setMaxBufferedDocs(int maxBufferedDocs)
this.maxBufferedDocs = maxBufferedDocs;
|
public void | setMaxFieldLength(int maxFieldLength)
this.maxFieldLength = maxFieldLength;
|
public void | setMaxMergeDocs(int maxMergeDocs)
this.maxMergeDocs = maxMergeDocs;
|
public void | setMergeFactor(int mergeFactor)
this.mergeFactor = mergeFactor;
|
public void | setName(java.lang.String name)
this.name = name;
|
public void | setOptimizeAfterCommit(int optimizeAfterCommit)
if(optimizeAfterCommit < DEFAULT_OPTIMIZE_COUNT )
return;
this.optimizeAfterCommit = optimizeAfterCommit;
|
public void | setSchemaFields(java.util.Collection fields)
this.schemaFields = fields;
|
public void | setServiceAnalyzer(org.apache.lucene.analysis.Analyzer serviceAnalyzer)
if (serviceAnalyzer == null)
return;
this.serviceAnalyzer = serviceAnalyzer;
|
public void | setUseCompoundFile(boolean useCompoundFile)
this.useCompoundFile = useCompoundFile;
|
public void | setUseTimedIndexer(boolean useTimedIndexer)
this.useTimedIndexer = useTimedIndexer;
|
public void | setWriteLockTimeout(long writeLockTimeout)
this.writeLockTimeout = writeLockTimeout;
|
public java.lang.String | toString()
StringBuilder builder = new StringBuilder(this.getClass().getName())
.append(" ");
builder.append("Name: ").append(this.name).append(" ");
builder.append("MaxBufferedDocs: ").append(this.maxBufferedDocs)
.append(" ");
builder.append("MaxFieldLength: ").append(this.maxFieldLength).append(
" ");
builder.append("MaxMergeDocs: ").append(this.maxMergeDocs).append(" ");
builder.append("MergeFactor: ").append(this.mergeFactor).append(" ");
builder.append("CommitLockTimeout: ").append(this.commitLockTimeout)
.append(" ");
builder.append("WriteLockTimeout: ").append(this.writeLockTimeout)
.append(" ");
builder.append("indexerIdleTime: ").append(this.indexerIdleTime)
.append(" ");
builder.append("useCompoundFile: ").append(this.useCompoundFile)
.append(" ");
builder.append("Added SchemaField instances: ").append(
this.schemaFields.size()).append(" ");
builder.append("IndexLocation: ").append(this.indexLocation)
.append(" ");
return builder.toString();
|