Package org.apache.lucene.index

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


   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    addIndex();
    IndexReader reader = IndexReader.open(lucenePath);
    System.out.println("�ĵ���:"+reader.numDocs());
    TermEnum tes = reader.terms();
    while(tes.next()){
      Term t = tes.term();
      System.out.println(t.toString());
    }
View Full Code Here


  SegmentInfos infos=new SegmentInfos();
  infos.read(targetDir);
  System.out.println("result segment count: "+infos.size());
 
  IndexReader r = IndexReader.open(targetDir,true);
  System.out.println("num docs: "+r.numDocs());
  r.close();
  }
}
View Full Code Here

    profile.setSuggestPopularTagsEnabled(false);
    indexer = new SearchSuggestIndexer();
    indexer.setSearchIndexProfile(profile);
    indexer.init();
    IndexReader reader = indexer.openSuggestIndexReader();
    assertEquals(13, reader.numDocs());
  }

  public void testInit2() throws Exception{
    profile = new SearchIndexProfile();
    profile.setSearchIndexDirectory("target/search-data");   
View Full Code Here

    indexer = new SearchSuggestIndexer();
    indexer.setGnizrDao(getGnizrDao());
    indexer.setSearchIndexProfile(profile);
    indexer.init();
    IndexReader reader = indexer.openSuggestIndexReader();
    assertEquals(4, reader.numDocs());
  }
 
 
  @Override
  protected IDataSet getDataSet() throws Exception {
View Full Code Here

        for (SearchableEntity indexedEntity : indexedEntities) {
            DirectoryProvider dirProvider = ((FullTextSession)em.getDelegate()).getSearchFactory().getDirectoryProviders(indexedEntity.getClazz())[0];
            IndexReader reader = IndexReader.open(dirProvider.getDirectory());

            indexedEntity.setNumOfIndexedDocuments(reader.numDocs());

            TermEnum te = reader.terms();
            long numTerms = 0;
            while (te.next()) numTerms++;
            indexedEntity.setNumOfIndexedTerms(numTerms);
View Full Code Here

        // 1. Open Index Reader
        File indexFile = new File(indexPath);
        Directory directory = FSDirectory.open(indexFile);
        IndexReader indexReader = IndexReader.open(directory);

        log.info("befor delete: indexReader.numDocs()=" + indexReader.numDocs());
        // 2. Delete old Document
        // loop over all documents in updateQueue
        for (int i = 0; i < updateCopy.size(); i++) {
          String resourceUrl = updateCopy.get(i).get(OlatDocument.RESOURCEURL_FIELD_NAME);
          Term term = new Term(OlatDocument.RESOURCEURL_FIELD_NAME, resourceUrl );
View Full Code Here

          Term term = new Term(OlatDocument.RESOURCEURL_FIELD_NAME, resourceUrl );
          log.info("deleteQueue:delete documents with resourceUrl='" + resourceUrl + "'");
          indexReader.deleteDocuments(term);
         
        }
        log.info("after delete: indexReader.numDocs()=" + indexReader.numDocs());
        // 3. Close reader
        indexReader.close();
        directory.close();
       
        // 4. open writer
View Full Code Here

    } finally {
      indexWriter.close();
    }
    final IndexReader indexReader = IndexReader.open(directory, true);
    try {
      assertEquals(1, indexReader.numDocs());
      final IndexSearcher indexSearcher = newSearcher(indexReader);
      try {
        final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
        query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
        query.add(new SpanTermQuery(new Term(FIELD, "fox")));
View Full Code Here

    } finally {
      indexWriter.close();
    }
    final IndexReader indexReader = IndexReader.open(directory, true);
    try {
      assertEquals(1, indexReader.numDocs());
      final IndexSearcher indexSearcher = newSearcher(indexReader);
      try {
        final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
        query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
        query.add(new SpanTermQuery(new Term(FIELD, "fox")));
View Full Code Here

    } finally {
      indexWriter.close();
    }
    final IndexReader indexReader = IndexReader.open(directory, true);
    try {
      assertEquals(1, indexReader.numDocs());
      final IndexSearcher indexSearcher = newSearcher(indexReader);
      try {
        // final DisjunctionMaxQuery query = new DisjunctionMaxQuery(1);
        // query.add(new SpanTermQuery(new Term(FIELD, "{fox}")));
        // query.add(new SpanTermQuery(new Term(FIELD, "fox")));
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.