Package org.apache.lucene.index

Examples of org.apache.lucene.index.IndexReader.deleteDocument()


      while ( termDocs.next() ) {
        int docIndex = termDocs.doc();
        if ( entityName.equals( reader.document( docIndex ).get( DocumentBuilder.CLASS_FIELDNAME ) ) ) {
          //remove only the one of the right class
          //loop all to remove all the matches (defensive code)
          reader.deleteDocument( docIndex );
        }
      }
    }
    catch (Exception e) {
      throw new HibernateException( "Unable to remove from Lucene index: " + entity + "#" + id, e );
View Full Code Here


    assertEquals(air.hasDeletions(), tir.hasDeletions());
    assertEquals(air.maxDoc(), tir.maxDoc());
    assertEquals(air.numDocs(), tir.numDocs());
    assertEquals(air.numDeletedDocs(), tir.numDeletedDocs());

    air.deleteDocument(3);
    tir.deleteDocument(3);

    assertEquals(air.isCurrent(), tir.isCurrent());
    assertEquals(air.hasDeletions(), tir.hasDeletions());
    assertEquals(air.maxDoc(), tir.maxDoc());
View Full Code Here

    assertEquals(air.hasDeletions(), tir.hasDeletions());
    assertEquals(air.maxDoc(), tir.maxDoc());
    assertEquals(air.numDocs(), tir.numDocs());
    assertEquals(air.numDeletedDocs(), tir.numDeletedDocs());

    air.deleteDocument(8);
    tir.deleteDocument(8);

    assertEquals(air.isCurrent(), tir.isCurrent());
    assertEquals(air.hasDeletions(), tir.hasDeletions());
    assertEquals(air.maxDoc(), tir.maxDoc());
View Full Code Here

        IndexReader reader = IndexReader.open(dir, false);
        Term aaa = new Term("content", "aaa");
        Term bbb = new Term("content", "bbb");
        Term ccc = new Term("content", "ccc");
        assertEquals(37, reader.docFreq(ccc));
        reader.deleteDocument(0);
        assertEquals(37, reader.docFreq(aaa));
        dir.tweakBufferSizes();
        reader.deleteDocument(4);
        assertEquals(reader.docFreq(bbb), 37);
        dir.tweakBufferSizes();
View Full Code Here

        Term ccc = new Term("content", "ccc");
        assertEquals(37, reader.docFreq(ccc));
        reader.deleteDocument(0);
        assertEquals(37, reader.docFreq(aaa));
        dir.tweakBufferSizes();
        reader.deleteDocument(4);
        assertEquals(reader.docFreq(bbb), 37);
        dir.tweakBufferSizes();

        IndexSearcher searcher = newSearcher(reader);
        ScoreDoc[] hits = searcher.search(new TermQuery(bbb), null, 1000).scoreDocs;
View Full Code Here

        IndexReader reader = IndexReader.open(dir, false);
        Term aaa = new Term("content", "aaa");
        Term bbb = new Term("content", "bbb");
        Term ccc = new Term("content", "ccc");
        assertEquals(37, reader.docFreq(ccc));
        reader.deleteDocument(0);
        assertEquals(37, reader.docFreq(aaa));
        dir.tweakBufferSizes();
        reader.deleteDocument(4);
        assertEquals(reader.docFreq(bbb), 37);
        dir.tweakBufferSizes();
View Full Code Here

        Term ccc = new Term("content", "ccc");
        assertEquals(37, reader.docFreq(ccc));
        reader.deleteDocument(0);
        assertEquals(37, reader.docFreq(aaa));
        dir.tweakBufferSizes();
        reader.deleteDocument(4);
        assertEquals(reader.docFreq(bbb), 37);
        dir.tweakBufferSizes();

        IndexSearcher searcher = newSearcher(reader);
        ScoreDoc[] hits = searcher.search(new TermQuery(bbb), null, 1000).scoreDocs;
View Full Code Here

        IndexReader reader = IndexReader.open(dir, false);
        Term aaa = new Term("content", "aaa");
        Term bbb = new Term("content", "bbb");
        Term ccc = new Term("content", "ccc");
        assertEquals(37, reader.docFreq(ccc));
        reader.deleteDocument(0);
        assertEquals(37, reader.docFreq(aaa));
        dir.tweakBufferSizes();
        reader.deleteDocument(4);
        assertEquals(reader.docFreq(bbb), 37);
        dir.tweakBufferSizes();
View Full Code Here

        Term ccc = new Term("content", "ccc");
        assertEquals(37, reader.docFreq(ccc));
        reader.deleteDocument(0);
        assertEquals(37, reader.docFreq(aaa));
        dir.tweakBufferSizes();
        reader.deleteDocument(4);
        assertEquals(reader.docFreq(bbb), 37);
        dir.tweakBufferSizes();

        IndexSearcher searcher = newSearcher(reader);
        ScoreDoc[] hits = searcher.search(new TermQuery(bbb), null, 1000).scoreDocs;
View Full Code Here

    bq.add(new TermQuery(new Term("key", "three")), BooleanClause.Occur.MUST);
    hits = is.search(bq, null, 1000).scoreDocs;
    assertEquals(1, hits.length);

    // delete a document:
    ir.deleteDocument(0);
    hits = is.search(new MatchAllDocsQuery(), null, 1000).scoreDocs;
    assertEquals(2, hits.length);
   
    // test parsable toString()
    QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "key", analyzer);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.