Package org.apache.lucene.index

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


            throws IOException {
        IndexReader reader = index.getIndexReader();
        try {
            checkRewritten(reader);
            Term idTerm = new Term(FieldNames.UUID, id.getUUID().toString());
            TermDocs tDocs = reader.termDocs(idTerm);
            int docNumber;
            Document doc;
            try {
                if (tDocs.next()) {
                    docNumber = tDocs.doc();
View Full Code Here


    openSearcher();
    IndexReader ir = searcher.getReader();
    TermDocs tdocs = null;
    boolean exists=false;
    try {
      tdocs = ir.termDocs(idTerm(indexedId));
      if (tdocs.next()) exists=true;
    } finally {
      try { if (tdocs != null) tdocs.close(); } catch (Exception e) {}
    }
    return exists;
View Full Code Here

      int numDeletes=0;

      closeWriter();
      openSearcher();
      IndexReader reader = searcher.getReader();
      TermDocs tdocs = reader.termDocs();
      String fieldname = idField.getName();

      for (Map.Entry<String,Integer> entry : pset.entrySet()) {
        String id = entry.getKey();
        int saveLast = entry.getValue()// save the last "saveLast" documents
View Full Code Here

                                 {
                                     TermDocs termDocs = null;
                                     try
                                     {
                                         // reader from resisted index should be
                                         termDocs = indexReader.termDocs(new Term(FieldNames.UUID, uuid));
                                         // node should be indexed if not found in persistent index
                                         addDoc = !termDocs.next();
                                     }
                                     catch (Exception e)
                                     {
View Full Code Here

    s.close();
    IndexReader reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
    try {
      int num = reader.numDocs();
      assertEquals( 1, num );
      TermDocs docs = reader.termDocs( new Term( "Abstract", "Hibernate" ) );
      org.apache.lucene.document.Document doc = reader.document( docs.doc() );
      assertFalse( docs.next() );
      docs = reader.termDocs( new Term( "Title", "Action" ) );
      doc = reader.document( docs.doc() );
      assertFalse( docs.next() );
View Full Code Here

      int num = reader.numDocs();
      assertEquals( 1, num );
      TermDocs docs = reader.termDocs( new Term( "Abstract", "Hibernate" ) );
      org.apache.lucene.document.Document doc = reader.document( docs.doc() );
      assertFalse( docs.next() );
      docs = reader.termDocs( new Term( "Title", "Action" ) );
      doc = reader.document( docs.doc() );
      assertFalse( docs.next() );
      assertEquals( "1", doc.getField( "id" ).stringValue() );
    }
    finally {
View Full Code Here

    reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
    try {
      int num = reader.numDocs();
      assertEquals( 2, num );
      TermDocs docs = reader.termDocs( new Term( "Abstract", "ejb" ) );
      assertTrue( docs.next() );
      org.apache.lucene.document.Document doc = reader.document( docs.doc() );
      assertFalse( docs.next() );
    }
    finally {
View Full Code Here

    reader = IndexReader.open( new File( getBaseIndexDir(), "Documents" ) );
    try {
      int num = reader.numDocs();
      assertEquals( 1, num );
      TermDocs docs = reader.termDocs( new Term( "title", "seam" ) );
      assertTrue( docs.next() );
      org.apache.lucene.document.Document doc = reader.document( docs.doc() );
      assertFalse( docs.next() );
      assertEquals( "2", doc.getField( "id" ).stringValue() );
    }
View Full Code Here

    reader = IndexReader.open( new File( getBaseIndexDir(), "Animal.1" ) );
    try {
      int num = reader.numDocs();
      assertEquals( 1, num );
      TermDocs docs = reader.termDocs( new Term( "name", "mouse" ) );
      assertTrue( docs.next() );
      org.apache.lucene.document.Document doc = reader.document( docs.doc() );
      assertFalse( docs.next() );
    }
    finally {
View Full Code Here

            throws IOException {
        IndexReader reader = index.getIndexReader();
        try {
            checkRewritten(reader);
            Term idTerm = new Term(FieldNames.UUID, id.getUUID().toString());
            TermDocs tDocs = reader.termDocs(idTerm);
            int docNumber;
            Document doc;
            try {
                if (tDocs.next()) {
                    docNumber = tDocs.doc();
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.