Package org.apache.lucene.document

Examples of org.apache.lucene.document.Document


      if (urlHash == null) {
        throw new NullPointerException(
            "Can't add document to the index. Doc is missing URL hash. doc:"
                + doc);
      }
      Document leadDoc = findLeadDocument(urlHash);
      if (leadDoc == null) {
        doc = DocumentCreator.addIndexTypeLead(doc);
        logger.debug("Added Lead Index Type to doc = " + doc.get(DocumentCreator.FIELD_BOOKMARK_ID));
      }
View Full Code Here


        throw new NullPointerException(
            "Can't delete document from the index. Doc is missing URL hash. doc:"
                + doc);
      }
      writer.flush();
      Document leadDoc = findLeadDocument(urlHash);
      if (leadDoc == null) {
        Document nonleadDoc = findNonLeadDocument(urlHash);
        if (nonleadDoc != null) {
          logger.debug("After deleting found a new Lead document. doc = " + nonleadDoc.get(DocumentCreator.FIELD_BOOKMARK_ID));
          nonleadDoc = DocumentCreator.addIndexTypeLead(nonleadDoc);
          doUpdate(nonleadDoc, writer);
        }
      }
    }
View Full Code Here

      indexWriter = new IndexWriter(directory, new KeywordAnalyzer(),
          true);
      for (Tag tag : tags) {
        String t = tag.getLabel();
        if (t.length() >= 3) {
          Document doc = createDocument(t);
          indexWriter.addDocument(doc);
        }
      }
      indexWriter.optimize();
    } finally {
View Full Code Here

    }
    return null;
  }

  private Document createDocument(String suggestTerm) {
    Document doc = new Document();
    doc.add(new Field("t", suggestTerm, Field.Store.YES,
        Field.Index.UN_TOKENIZED));
    return doc;
  }
View Full Code Here

          StringTokenizer tokenizer = new StringTokenizer(aline,
              "\n\r\f", false);
          while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken().trim();
            if (token != null) {
              Document doc = createDocument(token);
              indexWriter.addDocument(doc);
            }
          }
          aline = dataReader.readLine();
        }
View Full Code Here

  /* (non-Javadoc)
   * @see com.gnizr.core.bookmark.BookmarkListener#notifyAdded(com.gnizr.core.bookmark.BookmarkManager, com.gnizr.db.dao.Bookmark)
   */
  public void notifyAdded(BookmarkManager manager, Bookmark bookmark)
      throws Exception
    Document doc = DocumentCreator.createDocument(bookmark);
    if(doc != null){
      logger.debug("notify SearchIndexManager to addIndex: " + bookmark.toString());
      searchIndexManager.addIndex(doc);
    }
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.gnizr.core.bookmark.BookmarkListener#notifyDeleted(com.gnizr.core.bookmark.BookmarkManager, com.gnizr.db.dao.Bookmark)
   */
  public void notifyDeleted(BookmarkManager manager, Bookmark bookmark)
      throws Exception {
    Document doc = DocumentCreator.createDocument(bookmark);
    if(doc != null){
      logger.debug("notify SearchIndexManager to deleteIndex: " + bookmark.toString());
      searchIndexManager.deleteIndex(doc);
    }

View Full Code Here

  /* (non-Javadoc)
   * @see com.gnizr.core.bookmark.BookmarkListener#notifyUpdated(com.gnizr.core.bookmark.BookmarkManager, com.gnizr.db.dao.Bookmark, com.gnizr.db.dao.Bookmark)
   */
  public void notifyUpdated(BookmarkManager manager, Bookmark oldBookmark,
      Bookmark newBookmark) throws Exception {
    Document doc = DocumentCreator.createDocument(newBookmark);
    if(doc != null){
      logger.debug("notify SearchIndexManager to updateIndex: " + newBookmark.toString());
      searchIndexManager.updateIndex(doc);
    }

View Full Code Here

    bookmarkPager = new BookmarkPager(getGnizrDao());
   
    DaoResult<Bookmark> result = bookmarkPager.pageAllBookmark(new User(2));
    List<Bookmark> bmarks = result.getResult();
    for(Bookmark bm : bmarks){
      Document doc = DocumentCreator.createDocument(bm);     
      manager.addIndex(doc);
    }
   
    result = bookmarkPager.pageAllBookmark(new User(3));
    bmarks = result.getResult();
   
    for(Bookmark bm : bmarks){
      Document doc = DocumentCreator.createDocument(bm);
      manager.addIndex(doc);
    }
   
    Thread.sleep(10000);
   
View Full Code Here

    manager.setProfile(profile);
    manager.init();
   
    urlHash = "a1234567890";

    doc1 = new Document();
    doc1.add(DocumentCreator.createFieldUrlHash(urlHash));   
    doc1.add(DocumentCreator.createFieldBookmarkId(111));
   
    doc2 = new Document();
    doc2.add(DocumentCreator.createFieldUrlHash(urlHash));
    doc2.add(DocumentCreator.createFieldBookmarkId(112));
    doc2 = DocumentCreator.addIndexTypeLead(doc2);
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.document.Document

Copyright © 2018 www.massapicom. 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.