本文整理汇总了C++中DocumentPtr::removeField方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentPtr::removeField方法的具体用法?C++ DocumentPtr::removeField怎么用?C++ DocumentPtr::removeField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentPtr
的用法示例。
在下文中一共展示了DocumentPtr::removeField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createIndexNoClose
TEST_F(IndexWriterReaderTest, testUpdateDocument) {
bool optimize = true;
DirectoryPtr dir1 = newLucene<MockRAMDirectory>();
IndexWriterPtr writer = newLucene<IndexWriter>(dir1, newLucene<WhitespaceAnalyzer>(), IndexWriter::MaxFieldLengthLIMITED);
// create the index
createIndexNoClose(!optimize, L"index1", writer);
// get a reader
IndexReaderPtr r1 = writer->getReader();
EXPECT_TRUE(r1->isCurrent());
String id10 = r1->document(10)->getField(L"id")->stringValue();
DocumentPtr newDoc = r1->document(10);
newDoc->removeField(L"id");
newDoc->add(newLucene<Field>(L"id", StringUtils::toString(8000), Field::STORE_YES, Field::INDEX_NOT_ANALYZED));
writer->updateDocument(newLucene<Term>(L"id", id10), newDoc);
EXPECT_TRUE(!r1->isCurrent());
IndexReaderPtr r2 = writer->getReader();
EXPECT_TRUE(r2->isCurrent());
EXPECT_EQ(0, count(newLucene<Term>(L"id", id10), r2));
EXPECT_EQ(1, count(newLucene<Term>(L"id", StringUtils::toString(8000)), r2));
r1->close();
writer->close();
EXPECT_TRUE(r2->isCurrent());
IndexReaderPtr r3 = IndexReader::open(dir1, true);
EXPECT_TRUE(r3->isCurrent());
EXPECT_TRUE(r2->isCurrent());
EXPECT_EQ(0, count(newLucene<Term>(L"id", id10), r3));
EXPECT_EQ(1, count(newLucene<Term>(L"id", StringUtils::toString(8000)), r3));
writer = newLucene<IndexWriter>(dir1, newLucene<WhitespaceAnalyzer>(), IndexWriter::MaxFieldLengthLIMITED);
DocumentPtr doc = newLucene<Document>();
doc->add(newLucene<Field>(L"field", L"a b c", Field::STORE_NO, Field::INDEX_ANALYZED));
writer->addDocument(doc);
EXPECT_TRUE(r2->isCurrent());
EXPECT_TRUE(r3->isCurrent());
writer->close();
EXPECT_TRUE(!r2->isCurrent());
EXPECT_TRUE(!r3->isCurrent());
r2->close();
r3->close();
dir1->close();
}