Package org.apache.lucene.document

Examples of org.apache.lucene.document.DocumentStoredFieldVisitor


        IndexAndTaxonomy indexAndTaxonomy = _sm.getIndexReader(_language.presentationLanguage, _versionToken);
        _versionToken = indexAndTaxonomy.version;
        try {
            for ( ScoreDoc sdoc : tdocs.scoreDocs ) {
                DocumentStoredFieldVisitor docVisitor = new DocumentStoredFieldVisitor("_uuid");
                indexAndTaxonomy.indexReader.document(sdoc.doc, docVisitor);
                Document doc = docVisitor.getDocument();
                String uuid = doc.get("_uuid");
                if (uuid != null) response.add(uuid);
            }
        } finally {
            _sm.releaseIndexReader(indexAndTaxonomy);
View Full Code Here


      TopDocs tdocs = performQuery(context, 0, maxHits, false);
      IndexAndTaxonomy indexAndTaxonomy = _sm.getIndexReader(_language.presentationLanguage, _versionToken);
      _versionToken = indexAndTaxonomy.version;
      try {
          for ( ScoreDoc sdoc : tdocs.scoreDocs ) {
              DocumentStoredFieldVisitor docVisitor = new DocumentStoredFieldVisitor("_id", "_root", "_schema", "_createDate", "_changeDate",
                      "_source", "_isTemplate", "_title", "_uuid", "_isHarvested", "_owner", "_groupOwner");
              indexAndTaxonomy.indexReader.document(sdoc.doc, docVisitor);
              Document doc = docVisitor.getDocument();

              Metadata mdInfo = Metadata.createFromLuceneIndexDocument(doc);
              response.put(mdInfo.getId(), mdInfo);
          }
      } finally {
View Full Code Here

            TopDocs tdocs = searcher.search(query, filter, numberOfHits, sort);
           
            for( ScoreDoc sdoc : tdocs.scoreDocs ) {
                Map<String, String> values = new HashMap<String, String>();
               
                DocumentStoredFieldVisitor docVisitor = new DocumentStoredFieldVisitor(returnFields);
                reader.document(sdoc.doc, docVisitor);
                Document doc = docVisitor.getDocument();
               
                for( String fieldname : returnFields ) {
                    values.put(fieldname, doc.get(fieldname));
                }
               
View Full Code Here

        // Commented this out for lucene 4.0 and NRT indexing.  It shouldn't be needed I would guess but leave it here
        // for a bit longer:  Commented out since: Dec 10 2012
        // FIXME: strange lucene hack: sometimes it tries to load a deleted document
        // if (reader.isDeleted(i)) continue;
       
        DocumentStoredFieldVisitor idXLinkSelector = new DocumentStoredFieldVisitor("_id", "_hasxlinks");
        reader.document(i, idXLinkSelector);
        Document doc = idXLinkSelector.getDocument();
        String id = doc.get("_id");
        String hasxlinks = doc.get("_hasxlinks");
                if(Log.isDebugEnabled(Geonet.INDEX_ENGINE))
                    Log.debug(Geonet.INDEX_ENGINE, "Got id "+id+" : '"+hasxlinks+"'");
        if (id == null) {
View Full Code Here

        // Commented this out for lucene 4.0 and NRT indexing.  It shouldn't be needed I would guess but leave it here
        // for a bit longer:  Commented out since: Dec 10 2012
        // FIXME: strange lucene hack: sometimes it tries to load a deleted document
        // if (reader.isDeleted(i)) continue;
       
        DocumentStoredFieldVisitor idChangeDateSelector = new DocumentStoredFieldVisitor("_id", "_changeDate");
                reader.document(i, idChangeDateSelector);
                Document doc = idChangeDateSelector.getDocument();
        String id = doc.get("_id");
        if (id == null) {
          Log.error(Geonet.INDEX_ENGINE, "Document with no _id field skipped! Document is "+doc);
          continue;
        }
View Full Code Here

                    Collator stringCollator = Collator.getInstance();
                    stringCollator.setStrength(Collator.PRIMARY);
                    SortedSet<String> sortedValues = new TreeSet<String>(stringCollator);
          ObjectKeyIntOpenHashMap duplicateValues = new ObjectKeyIntOpenHashMap();
          for (int j = 0; j < hits.scoreDocs.length; j++) {
              DocumentStoredFieldVisitor selector = new DocumentStoredFieldVisitor(fields);
            reader.document(hits.scoreDocs[j].doc, selector);
            Document doc = selector.getDocument();

            // Skip templates and subTemplates
            String[] isTemplate = doc.getValues("_isTemplate");
            if (isTemplate[0] != null && !isTemplate[0].equals("n"))
              continue;
View Full Code Here

   */
  // TODO: we need a separate StoredField, so that the
  // Document returned here contains that class not
  // IndexableField
  public final Document document(int docID) throws IOException {
    final DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor();
    document(docID, visitor);
    return visitor.getDocument();
  }
View Full Code Here

   * Like {@link #document(int)} but only loads the specified
   * fields.  Note that this is simply sugar for {@link
   * DocumentStoredFieldVisitor#DocumentStoredFieldVisitor(Set)}.
   */
  public final Document document(int docID, Set<String> fieldsToLoad) throws IOException {
    final DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(fieldsToLoad);
    document(docID, visitor);
    return visitor.getDocument();
  }
View Full Code Here

    assertTrue(field != null);
    assertFalse(field.fieldType().storeTermVectors());
    assertFalse(field.fieldType().omitNorms());
    assertTrue(field.fieldType().indexOptions() == IndexOptions.DOCS_ONLY);

    DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(DocHelper.TEXT_FIELD_3_KEY);
    reader.document(0, visitor);
    final List<IndexableField> fields = visitor.getDocument().getFields();
    assertEquals(1, fields.size());
    assertEquals(DocHelper.TEXT_FIELD_3_KEY, fields.get(0).name());
    reader.close();
  }
View Full Code Here

  @Override
  protected Document retrieveDoc(IndexReader ir, int id) throws IOException {
    if (fieldsToLoad == null) {
      return ir.document(id);
    } else {
      DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(fieldsToLoad);
      ir.document(id, visitor);
      return visitor.getDocument();
    }
  }
View Full Code Here

TOP

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

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.