search

Home  >  Q&A  >  body text

java - Lucene wants to delete field as specified value data

Document document = new Document();
// 向Document对象中添加域信息
// 参数:1、域的名称;2、域的值;3、是否存储;
Field contentField = new TextField("content", labelformat(t.getContent()), Store.YES);
// storedFiled默认存储
Field tidField = new StoredField("tid", t.getTopicId());
// 将域添加到document对象中
document.add(contentField);
document.add(tidField);
// 将信息写入到索引库中
indexWriter.addDocument(document);

I want to delete the index data with tid 1, I tried it

indexWriter.deleteDocuments() 

But the input parameters can only be query or term objects, and it has never been successful.
What should be done correctly? ?

欧阳克欧阳克2764 days ago901

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-07-03 11:45:30

    Baidu has found a solution, try it and it will work
    http://www.it610.com/article/...

    reply
    0
  • Cancelreply