Package org.apache.lucene.index

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


      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

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

      reader = IndexReader.open(dir);
      termCounts = new int[reader.maxDoc()];
      try {
    termEnum = reader.terms(new Term(field,""));
    try {
        termDocs = reader.termDocs();
        do {
      Term term = termEnum.term();
      if (term != null && term.field().equals(fieldName)) {
          termDocs.seek(termEnum.term());
          while (termDocs.next()) {
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

    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

    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

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.