List of usage examples for org.apache.lucene.document DocumentStoredFieldVisitor DocumentStoredFieldVisitor
public DocumentStoredFieldVisitor()
From source file:com.core.nlp.index.IndexReader.java
License:Apache License
/** * Returns the stored fields of the <code>n</code><sup>th</sup> * <code>Document</code> in this index. This is just * sugar for using {@link DocumentStoredFieldVisitor}. * <p>// ww w . ja v a 2 s . com * <b>NOTE:</b> for performance reasons, this method does not check if the * requested document is deleted, and therefore asking for a deleted document * may yield unspecified results. Usually this is not required, however you * can test if the doc is deleted by checking the {@link * Bits} returned from {@link MultiFields#getLiveDocs}. * * <b>NOTE:</b> only the content of a field is returned, * if that field was stored during indexing. Metadata * like boost, omitNorm, IndexOptions, tokenized, etc., * are not preserved. * * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ // 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(); }
From source file:fi.semantum.strategia.Lucene.java
License:Open Source License
public static synchronized List<String> search(String databaseId, String search) throws IOException { ArrayList<String> result = new ArrayList<String>(); IndexReader reader = null;// w w w. ja va 2 s . co m try { reader = DirectoryReader.open(getDirectory(databaseId)); IndexSearcher searcher = new IndexSearcher(reader); QueryParser parser = new QueryParser(Version.LUCENE_4_9, "text", getAnalyzer()); parser.setAllowLeadingWildcard(true); Query query = parser.parse(search); TopDocs docs = searcher.search(query, Integer.MAX_VALUE); for (ScoreDoc scoreDoc : docs.scoreDocs) { try { DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(); reader.document(scoreDoc.doc, visitor); Document doc = visitor.getDocument(); result.add(doc.get("uuid")); } catch (CorruptIndexException e) { throw new IOException(e); } } } catch (ParseException e) { throw new IOException(e); } finally { if (reader != null) reader.close(); } return result; }
From source file:lux.CachingDocReader.java
License:Mozilla Public License
private XdmNode get(int docID, int luceneDocID, IndexReader reader) throws IOException { XdmNode node = cache.get(docID);// ww w . j a v a 2 s .c om if (node != null) { ++cacheHits; return node; } DocumentStoredFieldVisitor fieldSelector = new DocumentStoredFieldVisitor(); reader.document(luceneDocID, fieldSelector); Document document = fieldSelector.getDocument(); return getXdmNode(docID, document); }
From source file:org.apache.blur.mapreduce.lib.GenericRecordReader.java
License:Apache License
private void fetchBlurRecord() throws IOException { DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(); _fieldsReader.visitDocument(_docId, visitor); BlurRecord blurRecord = new BlurRecord(); String rowId = RowDocumentUtil.readRecord(visitor.getDocument(), blurRecord); blurRecord.setRowId(rowId);//from w w w .j a v a2s . c o m _rowId = new Text(rowId); _tableBlurRecord = new TableBlurRecord(_table, blurRecord); }