org.apache.lucene.index.TermEnum Java Examples
The following examples show how to use
org.apache.lucene.index.TermEnum.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MemoryIndex.java From netbeans with Apache License 2.0 | 5 votes |
@Override public <T> void queryTerms( @NonNull Collection<? super T> result, @NullAllowed Term start, @NonNull StoppableConvertor<Term, T> filter, @NullAllowed AtomicBoolean cancel) throws IOException, InterruptedException { Parameters.notNull("result", result); //NOI18N Parameters.notNull("filter", filter); //NOI18N lock.readLock().lock(); try { final IndexReader in = getReader(); if (in == null) { return; } final TermEnum terms = start == null ? in.terms () : in.terms (start); try { do { if (cancel != null && cancel.get()) { throw new InterruptedException (); } final Term currentTerm = terms.term(); if (currentTerm != null) { final T vote = filter.convert(currentTerm); if (vote != null) { result.add(vote); } } } while (terms.next()); } catch (StoppableConvertor.Stop stop) { //Stop iteration of TermEnum } finally { terms.close(); } } finally { lock.readLock().unlock(); } }
Example #2
Source File: Convertors.java From netbeans with Apache License 2.0 | 5 votes |
@Override public T convert(@NonNull final TermEnum terms) throws StoppableConvertor.Stop { final Term currentTerm = terms.term(); if (currentTerm == null) { return null; } return delegate.convert(currentTerm); }
Example #3
Source File: Convertors.java From netbeans with Apache License 2.0 | 5 votes |
@Override public T convert(TermEnum terms) throws StoppableConvertor.Stop { final Term currentTerm = terms.term(); if (currentTerm == null) { return null; } final int freq = terms.docFreq(); return delegate.convert(accessor.setTermFreq(tf, currentTerm, freq)); }
Example #4
Source File: LuceneUnsortedIntTermDocIterator.java From imhotep with Apache License 2.0 | 5 votes |
static LuceneUnsortedIntTermDocIterator create(final IndexReader r, final String field) throws IOException { final TermEnum terms = r.terms(new Term(field, "")); final TermDocs termDocs; try { termDocs = r.termDocs(); } catch (IOException e) { try { terms.close(); } catch (IOException e1) { log.error("error closing TermEnum", e1); } throw e; } return new LuceneUnsortedIntTermDocIterator(field, terms, termDocs); }
Example #5
Source File: QueryUtil.java From netbeans with Apache License 2.0 | 4 votes |
private TermEnum getTermEnum(@NonNull final IndexReader reader) { return new TermEnum () { private Iterator<String> pkgsIt = pkgs.iterator(); private String current; { next(); } @Override public boolean next() { if (pkgsIt == null) { throw new IllegalStateException("Already closed."); //NOI18N } if (pkgsIt.hasNext()) { current = pkgsIt.next(); return true; } else { current = null; return false; } } @Override public Term term() { return current == null ? null : new Term (DocumentUtil.FIELD_PACKAGE_NAME, current); } @Override public int docFreq() { return current == null ? -1 : 0; } @Override public void close() throws IOException { pkgsIt = null; } }; }
Example #6
Source File: Convertors.java From netbeans with Apache License 2.0 | 4 votes |
static <T> StoppableConvertor<TermEnum,T> newTermEnumToTermConvertor( @NonNull StoppableConvertor<Term,T> delegate) { return new TermEnumToTerm<T>(delegate); }
Example #7
Source File: Convertors.java From netbeans with Apache License 2.0 | 4 votes |
static <T> StoppableConvertor<TermEnum,T> newTermEnumToFreqConvertor( @NonNull StoppableConvertor<Index.WithTermFrequencies.TermFreq,T> delegate) { return new TermEnumToFreq<T>(delegate); }
Example #8
Source File: FilterIndexReaderByStringId.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void seek(TermEnum termEnum) throws IOException { // Seek is left to the base implementation in.seek(termEnum); }
Example #9
Source File: ReferenceCountingReadOnlyIndexReaderFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void seek(TermEnum termEnum) throws IOException { throw new UnsupportedOperationException(); }
Example #10
Source File: LuceneIntTermIterator.java From imhotep with Apache License 2.0 | 4 votes |
@Override public TermEnum termEnum() { sanityCheck(); return prefixQueue.element().termEnum; }
Example #11
Source File: LuceneUnsortedIntTermDocIterator.java From imhotep with Apache License 2.0 | 4 votes |
LuceneUnsortedIntTermDocIterator(String field, TermEnum terms, TermDocs termDocs) { this.field = field.intern(); this.terms = terms; this.termDocs = termDocs; }
Example #12
Source File: LuceneStringTermIterator.java From imhotep with Apache License 2.0 | 4 votes |
@Override public TermEnum termEnum() { sanityCheck(); return termEnum; }
Example #13
Source File: LuceneTermIterator.java From imhotep with Apache License 2.0 | votes |
public TermEnum termEnum();