/** * Builds a MemoryIndex from a lucene {@link Document} using an analyzer * @param document the document to index * @param analyzer the analyzer to use * @param storeOffsets <code>true</code> if offsets should be stored * @param storePayloads <code>true</code> if payloads should be stored * @return a MemoryIndex */ public static MemoryIndex fromDocument(Iterable<? extends IndexableField> document, Analyzer analyzer, boolean storeOffsets, boolean storePayloads) { return fromDocument(document, analyzer, storeOffsets, storePayloads, 0); }
/** * Builds a MemoryIndex from a lucene {@link Document} using an analyzer * * @param document the document to index * @param analyzer the analyzer to use * @return a MemoryIndex */ public static MemoryIndex fromDocument(Iterable<? extends IndexableField> document, Analyzer analyzer) { return fromDocument(document, analyzer, false, false, 0); }
/** * Builds a MemoryIndex from a lucene {@link Document} using an analyzer * @param document the document to index * @param analyzer the analyzer to use * @param storeOffsets <code>true</code> if offsets should be stored * @param storePayloads <code>true</code> if payloads should be stored * @return a MemoryIndex */ public static MemoryIndex fromDocument(Document document, Analyzer analyzer, boolean storeOffsets, boolean storePayloads) { return fromDocument(document, analyzer, storeOffsets, storePayloads, 0); }
/** * Builds a MemoryIndex from a lucene {@link Document} using an analyzer * * @param document the document to index * @param analyzer the analyzer to use * @return a MemoryIndex */ public static MemoryIndex fromDocument(Document document, Analyzer analyzer) { return fromDocument(document, analyzer, false, false, 0); }
public void buildTermVector(int docid) throws IOException { /* */ Set<String> fieldList = new HashSet<>(); fieldList.add("content"); Document doc = reader.document(docid, fieldList); MemoryIndex mi = MemoryIndex.fromDocument(doc, new StandardAnalyzer()); IndexReader mr = mi.createSearcher().getIndexReader(); Terms t = mr.leaves().get(0).reader().terms("content"); if ((t != null) && (t.size()>0)) { TermsEnum te = t.iterator(); BytesRef term = null; System.out.println(t.size()); while ((term = te.next()) != null) { System.out.println("BytesRef: " + term.utf8ToString()); System.out.println("docFreq: " + te.docFreq()); System.out.println("totalTermFreq: " + te.totalTermFreq()); } } }
MemoryIndex mi = MemoryIndex.fromDocument(doc, new StandardAnalyzer()); IndexReader mr = mi.createSearcher().getIndexReader();
docSearcher = createMultiDocumentSearcher(analyzer, docs); } else { MemoryIndex memoryIndex = MemoryIndex.fromDocument(docs.get(0).rootDoc(), analyzer, true, false); docSearcher = memoryIndex.createSearcher(); docSearcher.setQueryCache(null);
docSearcher = createMultiDocumentSearcher(analyzer, docs); } else { MemoryIndex memoryIndex = MemoryIndex.fromDocument(docs.get(0).rootDoc(), analyzer, true, false); docSearcher = memoryIndex.createSearcher(); docSearcher.setQueryCache(null);