/** * A {@link TermsEnum} that iterates only highest resolution geo prefix coded terms. * * @see #buildFromTerms(TermsEnum) */ public static TermsEnum wrapGeoPointTerms(TermsEnum termsEnum) { return new FilteredTermsEnum(termsEnum, false) { @Override protected AcceptStatus accept(BytesRef term) throws IOException { // accept only the max resolution terms // todo is this necessary? return GeoPointField.getPrefixCodedShift(term) == GeoPointField.PRECISION_STEP * 4 ? AcceptStatus.YES : AcceptStatus.END; } }; }
/** * A {@link TermsEnum} that iterates only full precision prefix coded 64 bit values. * * @see #buildFromTerms(TermsEnum) */ public static TermsEnum wrapNumeric64Bit(TermsEnum termsEnum) { return new FilteredTermsEnum(termsEnum, false) { @Override protected AcceptStatus accept(BytesRef term) throws IOException { // we stop accepting terms once we moved across the prefix codec terms - redundant values! return LegacyNumericUtils.getPrefixCodedLongShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; } }; }
/** * A {@link TermsEnum} that iterates only full precision prefix coded 32 bit values. * * @see #buildFromTerms(TermsEnum) */ public static TermsEnum wrapNumeric32Bit(TermsEnum termsEnum) { return new FilteredTermsEnum(termsEnum, false) { @Override protected AcceptStatus accept(BytesRef term) throws IOException { // we stop accepting terms once we moved across the prefix codec terms - redundant values! return LegacyNumericUtils.getPrefixCodedIntShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; } }; }
/** * A {@link TermsEnum} that iterates only highest resolution geo prefix coded terms. * * @see #buildFromTerms(TermsEnum) */ public static TermsEnum wrapGeoPointTerms(TermsEnum termsEnum) { return new FilteredTermsEnum(termsEnum, false) { @Override protected AcceptStatus accept(BytesRef term) throws IOException { // accept only the max resolution terms // todo is this necessary? return GeoEncodingUtils.getPrefixCodedShift(term) == GeoPointField.PRECISION_STEP * 4 ? AcceptStatus.YES : AcceptStatus.END; } }; }
/** * A {@link TermsEnum} that iterates only full precision prefix coded 64 bit values. * * @see #buildFromTerms(TermsEnum) */ public static TermsEnum wrapNumeric64Bit(TermsEnum termsEnum) { return new FilteredTermsEnum(termsEnum, false) { @Override protected AcceptStatus accept(BytesRef term) throws IOException { // we stop accepting terms once we moved across the prefix codec terms - redundant values! return NumericUtils.getPrefixCodedLongShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; } }; }
/** * A {@link TermsEnum} that iterates only full precision prefix coded 32 bit values. * * @see #buildFromTerms(TermsEnum) */ public static TermsEnum wrapNumeric32Bit(TermsEnum termsEnum) { return new FilteredTermsEnum(termsEnum, false) { @Override protected AcceptStatus accept(BytesRef term) throws IOException { // we stop accepting terms once we moved across the prefix codec terms - redundant values! return NumericUtils.getPrefixCodedIntShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; } }; }
/** * Filters the given {@link TermsEnum} by accepting only prefix coded 32 bit * terms with a shift value of <tt>0</tt>. * * @param termsEnum * the terms enum to filter * @return a filtered {@link TermsEnum} that only returns prefix coded 32 bit * terms with a shift value of <tt>0</tt>. */ public static TermsEnum filterPrefixCodedInts(TermsEnum termsEnum) { return new FilteredTermsEnum(termsEnum, false) { @Override protected AcceptStatus accept(BytesRef term) { return NumericUtils.getPrefixCodedIntShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; } }; }
@Override protected FilteredTermsEnum getTermsEnum(Terms terms, AttributeSource atts) throws IOException { return new RegexTermsEnum(terms.iterator(null), term, regexImpl); }
/** * Filters the given {@link TermsEnum} by accepting only prefix coded 64 bit * terms with a shift value of <tt>0</tt>. * * @param termsEnum * the terms enum to filter * @return a filtered {@link TermsEnum} that only returns prefix coded 64 bit * terms with a shift value of <tt>0</tt>. */ public static TermsEnum filterPrefixCodedLongs(TermsEnum termsEnum) { return new FilteredTermsEnum(termsEnum, false) { @Override protected AcceptStatus accept(BytesRef term) { return NumericUtils.getPrefixCodedLongShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; } }; }