本文整理汇总了Python中org.apache.lucene.index.IndexWriter.optimize方法的典型用法代码示例。如果您正苦于以下问题:Python IndexWriter.optimize方法的具体用法?Python IndexWriter.optimize怎么用?Python IndexWriter.optimize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.index.IndexWriter
的用法示例。
在下文中一共展示了IndexWriter.optimize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reindex
# 需要导入模块: from org.apache.lucene.index import IndexWriter [as 别名]
# 或者: from org.apache.lucene.index.IndexWriter import optimize [as 别名]
def reindex(self):
writer = IndexWriter(SimpleFSDirectory(File(self.corpus.path)), self.corpus.analyzer, False, IndexWriter.MaxFieldLength.LIMITED)
indexutils.reindex_all(self.reader, writer, self.corpus.analyzer)
writer.optimize()
writer.close()
self.parent.write({'message': "Reindex successful. Corpus analyzer is now set to %s." % (self.corpus.analyzer_str,)})
self.parent.write({'status': "Ready!"})
示例2: removeindex
# 需要导入模块: from org.apache.lucene.index import IndexWriter [as 别名]
# 或者: from org.apache.lucene.index.IndexWriter import optimize [as 别名]
def removeindex(self, data):
writer = IndexWriter(
self.d, self.conf)
writer.deleteDocuments(lucene.Term("_id", data['record']['_id']))
writer.optimize()
writer.close()
示例3: updateindex
# 需要导入模块: from org.apache.lucene.index import IndexWriter [as 别名]
# 或者: from org.apache.lucene.index.IndexWriter import optimize [as 别名]
def updateindex(self, data):
writer = IndexWriter(
self.d, self.conf)
doc = self.buildDocument(data['fields'], data['record'])
writer.updateDocument(lucene.Term("_id", data['record']['_id']), doc)
writer.optimize()
writer.close()
示例4: xmlrpc_indexDocument
# 需要导入模块: from org.apache.lucene.index import IndexWriter [as 别名]
# 或者: from org.apache.lucene.index.IndexWriter import optimize [as 别名]
def xmlrpc_indexDocument(self, instance, id, text):
"""Index a new document."""
self.xmlrpc_unindexDocument(instance, id)
# Create a document and add two fields to it.
doc = Document()
doc.add(Field('id', id, Field.Store.YES, Field.Index.UN_TOKENIZED))
doc.add(Field('text', text, Field.Store.YES, Field.Index.TOKENIZED))
doc.add(Field('instance', instance, Field.Store.YES, Field.Index.UN_TOKENIZED))
# Write the document into the index.
writer = IndexWriter(self.indexPath, self.analyzer, 0)
writer.addDocument(doc)
writer.optimize()
writer.close()
log('Insert: Instance: %s Document: %s' %(instance, id))
return 1
示例5: _init_index
# 需要导入模块: from org.apache.lucene.index import IndexWriter [as 别名]
# 或者: from org.apache.lucene.index.IndexWriter import optimize [as 别名]
def _init_index(self):
if not os.path.exists(self.corpus.path):
os.mkdir(self.corpus.path)
try:
searcher = IndexSearcher(SimpleFSDirectory(File(self.corpus.path)), True)
#except lucene.JavaError:
except:
analyzer = self.corpus.analyzer
writer = IndexWriter(SimpleFSDirectory(File(self.corpus.path)), analyzer, True, IndexWriter.MaxFieldLength.LIMITED)
writer.setMaxFieldLength(1048576)
writer.optimize()
writer.close()
self.lucene_index = SimpleFSDirectory(File(self.corpus.path))
self.searcher = IndexSearcher(self.lucene_index, True)
self.reader = IndexReader.open(self.lucene_index, True)
self.analyzer = self.corpus.analyzer
示例6: update
# 需要导入模块: from org.apache.lucene.index import IndexWriter [as 别名]
# 或者: from org.apache.lucene.index.IndexWriter import optimize [as 别名]
from java.net import URL
from java.util import Date
# from de.nava.informa.impl.basic import ChannelBuilder
# from de.nava.informa.utils import ChannelRegistry
from de.nava.informa.impl.basic import Item
from de.nava.informa.search import ItemDocument
from org.apache.lucene.analysis.standard import StandardAnalyzer
from org.apache.lucene.index import IndexWriter
# update (3rd arg) index writer in directory (first arg)
start_time = Date()
writer = IndexWriter("index", StandardAnalyzer(), 0)
# create new (dummy) item
item = Item("Informa released", "blubb",
URL("http://nava.de/news/2002/06/25"))
item.setFound(Date())
# add new item to index
writer.addDocument(ItemDocument.makeDocument(item))
writer.optimize()
writer.close()
end_time = Date()
print "updating the index took %d milliseconds in total." \
% (end_time.getTime() - start_time.getTime())