本文整理汇总了Java中org.apache.lucene.index.IndexDeletionPolicy类的典型用法代码示例。如果您正苦于以下问题:Java IndexDeletionPolicy类的具体用法?Java IndexDeletionPolicy怎么用?Java IndexDeletionPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IndexDeletionPolicy类属于org.apache.lucene.index包,在下文中一共展示了IndexDeletionPolicy类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IndexAndTaxonomyRevision
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
/**
* Constructor over the given {@link IndexWriter}. Uses the last
* {@link IndexCommit} found in the {@link Directory} managed by the given
* writer.
*/
public IndexAndTaxonomyRevision(IndexWriter indexWriter, SnapshotDirectoryTaxonomyWriter taxoWriter)
throws IOException {
IndexDeletionPolicy delPolicy = indexWriter.getConfig().getIndexDeletionPolicy();
if (!(delPolicy instanceof SnapshotDeletionPolicy)) {
throw new IllegalArgumentException("IndexWriter must be created with SnapshotDeletionPolicy");
}
this.indexWriter = indexWriter;
this.taxoWriter = taxoWriter;
this.indexSDP = (SnapshotDeletionPolicy) delPolicy;
this.taxoSDP = taxoWriter.getDeletionPolicy();
this.indexCommit = indexSDP.snapshot();
this.taxoCommit = taxoSDP.snapshot();
this.version = revisionVersion(indexCommit, taxoCommit);
this.sourceFiles = revisionFiles(indexCommit, taxoCommit);
}
示例2: test
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
public void test() throws Exception {
Directory dir = null;
IndexDeletionPolicy policy = new KeepOnlyLastCommitDeletionPolicy();
SnapshotDeletionPolicy snapshotter = new SnapshotDeletionPolicy(policy);
IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_41,
AosAnalyser.NO_LIMIT_TOKEN_COUNT_SIMPLE_ANALYSER);
conf.setIndexDeletionPolicy(snapshotter);
IndexWriter writer = new IndexWriter(dir, conf);
try {
IndexCommit commit = snapshotter.snapshot("unique-id");
Collection<String> fileNames = commit.getFileNames();
/* <iterate over & copy files from fileNames> */
}
finally {
snapshotter.release("unique-id");
}
}
示例3: configure
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
@Override
protected void configure() {
bind(IndexDeletionPolicy.class)
.annotatedWith(Names.named("actual"))
.to(KeepOnlyLastDeletionPolicy.class)
.asEagerSingleton();
bind(SnapshotDeletionPolicy.class)
.asEagerSingleton();
}
示例4: updateIndex
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
public void updateIndex(Directory dir, int base, int numDocs,
IndexDeletionPolicy policy) throws IOException {
IndexWriter writer =
new IndexWriter(dir, false, new StandardAnalyzer(), policy);
writer.setMaxBufferedDocs(maxBufferedDocs);
writer.setMergeFactor(1000);
for (int i = 0; i < numDocs; i++) {
addDoc(writer, base + i);
}
writer.close();
}
示例5: getIndexDeletionPolicy
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
public static IndexDeletionPolicy getIndexDeletionPolicy(Config config) {
String deletionPolicyName = config.get("deletion.policy", "org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy");
if (deletionPolicyName.equals(NoDeletionPolicy.class.getName())) {
return NoDeletionPolicy.INSTANCE;
} else {
try {
return Class.forName(deletionPolicyName).asSubclass(IndexDeletionPolicy.class).newInstance();
} catch (Exception e) {
throw new RuntimeException("unable to instantiate class '" + deletionPolicyName + "' as IndexDeletionPolicy", e);
}
}
}
示例6: IndexRevision
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
/**
* Constructor over the given {@link IndexWriter}. Uses the last
* {@link IndexCommit} found in the {@link Directory} managed by the given
* writer.
*/
public IndexRevision(IndexWriter writer) throws IOException {
IndexDeletionPolicy delPolicy = writer.getConfig().getIndexDeletionPolicy();
if (!(delPolicy instanceof SnapshotDeletionPolicy)) {
throw new IllegalArgumentException("IndexWriter must be created with SnapshotDeletionPolicy");
}
this.writer = writer;
this.sdp = (SnapshotDeletionPolicy) delPolicy;
this.commit = sdp.snapshot();
this.version = revisionVersion(commit);
this.sourceFiles = revisionFiles(commit);
}
示例7: SolrIndexWriter
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
private SolrIndexWriter(String name, String path, Directory directory, boolean create, IndexSchema schema, SolrIndexConfig config, IndexDeletionPolicy delPolicy, Codec codec) throws IOException {
super(directory,
config.toIndexWriterConfig(schema).
setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND).
setIndexDeletionPolicy(delPolicy).setCodec(codec)
);
log.debug("Opened Writer " + name);
this.name = name;
infoStream = getConfig().getInfoStream();
this.directory = directory;
numOpens.incrementAndGet();
}
示例8: initDeletionPolicy
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
private void initDeletionPolicy() {
PluginInfo info = solrConfig.getPluginInfo(IndexDeletionPolicy.class.getName());
IndexDeletionPolicy delPolicy = null;
if(info != null){
delPolicy = createInstance(info.className,IndexDeletionPolicy.class,"Deletion Policy for SOLR");
if (delPolicy instanceof NamedListInitializedPlugin) {
((NamedListInitializedPlugin) delPolicy).init(info.initArgs);
}
} else {
delPolicy = new SolrDeletionPolicy();
}
solrDelPolicy = new IndexDeletionPolicyWrapper(delPolicy);
}
示例9: SolrIndexWriter
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
private SolrIndexWriter(String name, String path, Directory directory, boolean create, IndexSchema schema, SolrIndexConfig config, IndexDeletionPolicy delPolicy, Codec codec) throws IOException {
super(directory,
config.toIndexWriterConfig(schema).
setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND).
setIndexDeletionPolicy(delPolicy).setCodec(codec).setInfoStream(toInfoStream(config))
);
log.debug("Opened Writer " + name);
this.name = name;
numOpens.incrementAndGet();
}
示例10: initDeletionPolicy
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
private void initDeletionPolicy() {
PluginInfo info = solrConfig.getPluginInfo(IndexDeletionPolicy.class.getName());
IndexDeletionPolicy delPolicy = null;
if(info != null) {
delPolicy = createInstance(info.className, IndexDeletionPolicy.class, "Deletion Policy for SOLR");
if(delPolicy instanceof NamedListInitializedPlugin) {
((NamedListInitializedPlugin) delPolicy).init(info.initArgs);
}
} else {
delPolicy = new SolrDeletionPolicy();
}
solrDelPolicy = new IndexDeletionPolicyWrapper(delPolicy);
}
示例11: SolrIndexWriter
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
private SolrIndexWriter(String name, String path, Directory directory, boolean create, IndexSchema schema, SolrIndexConfig config, IndexDeletionPolicy delPolicy, Codec codec) throws IOException {
super(directory,
config.toIndexWriterConfig(schema).
setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND).
setIndexDeletionPolicy(delPolicy).setCodec(codec)
);
log.debug("Opened Writer " + name);
this.name = name;
numOpens.incrementAndGet();
}
示例12: SnapshotDeletionPolicy
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
/**
* Constructs a new snapshot deletion policy that wraps the provided deletion policy.
*/
@Inject
public SnapshotDeletionPolicy(@Named("actual") IndexDeletionPolicy primary) {
super(((IndexShardComponent) primary).shardId(), ((IndexShardComponent) primary).indexSettings());
this.primary = primary;
}
示例13: clone
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
@Override
public IndexDeletionPolicy clone() {
// Lucene IW makes a clone internally but since we hold on to this instance
// the clone will just be the identity. See InternalEngine recovery why we need this.
return this;
}
示例14: IndexDeletionPolicyWrapper
import org.apache.lucene.index.IndexDeletionPolicy; //导入依赖的package包/类
public IndexDeletionPolicyWrapper(IndexDeletionPolicy deletionPolicy) {
this.deletionPolicy = deletionPolicy;
}