Java Code Examples for org.apache.lucene.index.DocValues#isCacheable()
The following examples show how to use
org.apache.lucene.index.DocValues#isCacheable() .
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: DocValuesFieldExistsQuery.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) { return new ConstantScoreWeight(this, boost) { @Override public Scorer scorer(LeafReaderContext context) throws IOException { DocIdSetIterator iterator = getDocValuesDocIdSetIterator(field, context.reader()); if (iterator == null) { return null; } return new ConstantScoreScorer(this, score(), scoreMode, iterator); } @Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); } }; }
Example 2
Source File: TestLRUQueryCache.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return new ConstantScoreWeight(this, 1) { @Override public Scorer scorer(LeafReaderContext context) throws IOException { scorerCreatedCount.incrementAndGet(); return new ConstantScoreScorer(this, 1, scoreMode, DocIdSetIterator.all(context.reader().maxDoc())); } @Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); } }; }
Example 3
Source File: BBoxValueSource.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, strategy.field_minX, strategy.field_minY, strategy.field_maxX, strategy.field_maxY); }
Example 4
Source File: DistanceValueSource.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, strategy.getFieldNameX(), strategy.getFieldNameY()); }
Example 5
Source File: SerializedDVStrategy.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, fieldName); }
Example 6
Source File: DocValuesTermsQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return new ConstantScoreWeight(this, boost) { @Override public Scorer scorer(LeafReaderContext context) throws IOException { final SortedSetDocValues values = DocValues.getSortedSet(context.reader(), field); final LongBitSet bits = new LongBitSet(values.getValueCount()); boolean matchesAtLeastOneTerm = false; TermIterator iterator = termData.iterator(); for (BytesRef term = iterator.next(); term != null; term = iterator.next()) { final long ord = values.lookupTerm(term); if (ord >= 0) { matchesAtLeastOneTerm = true; bits.set(ord); } } if (matchesAtLeastOneTerm == false) { return null; } return new ConstantScoreScorer(this, score(), scoreMode, new TwoPhaseIterator(values) { @Override public boolean matches() throws IOException { for (long ord = values.nextOrd(); ord != SortedSetDocValues.NO_MORE_ORDS; ord = values.nextOrd()) { if (bits.get(ord)) { return true; } } return false; } @Override public float matchCost() { return 3; // lookup in a bitset } }); } @Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); } }; }
Example 7
Source File: DoubleValuesSource.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); }
Example 8
Source File: LongValuesSource.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); }
Example 9
Source File: LatLonDocValuesPointInPolygonQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return new ConstantScoreWeight(this, boost) { final Component2D tree = LatLonGeometry.create(polygons); final GeoEncodingUtils.PolygonPredicate polygonPredicate = GeoEncodingUtils.createComponentPredicate(tree); @Override public Scorer scorer(LeafReaderContext context) throws IOException { final SortedNumericDocValues values = context.reader().getSortedNumericDocValues(field); if (values == null) { return null; } final TwoPhaseIterator iterator = new TwoPhaseIterator(values) { @Override public boolean matches() throws IOException { for (int i = 0, count = values.docValueCount(); i < count; ++i) { final long value = values.nextValue(); final int lat = (int) (value >>> 32); final int lon = (int) (value & 0xFFFFFFFF); if (polygonPredicate.test(lat, lon)) { return true; } } return false; } @Override public float matchCost() { return 1000f; // TODO: what should it be? } }; return new ConstantScoreScorer(this, boost, scoreMode, iterator); } @Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); } }; }
Example 10
Source File: LatLonDocValuesDistanceQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return new ConstantScoreWeight(this, boost) { private final GeoEncodingUtils.DistancePredicate distancePredicate = GeoEncodingUtils.createDistancePredicate(latitude, longitude, radiusMeters); @Override public Scorer scorer(LeafReaderContext context) throws IOException { final SortedNumericDocValues values = context.reader().getSortedNumericDocValues(field); if (values == null) { return null; } final TwoPhaseIterator iterator = new TwoPhaseIterator(values) { @Override public boolean matches() throws IOException { for (int i = 0, count = values.docValueCount(); i < count; ++i) { final long value = values.nextValue(); final int lat = (int) (value >>> 32); final int lon = (int) (value & 0xFFFFFFFF); if (distancePredicate.test(lat, lon)) { return true; } } return false; } @Override public float matchCost() { return 100f; // TODO: what should it be? } }; return new ConstantScoreScorer(this, boost, scoreMode, iterator); } @Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); } }; }
Example 11
Source File: XYDocValuesPointInGeometryQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return new ConstantScoreWeight(this, boost) { final Component2D component2D = XYGeometry.create(geometries); @Override public Scorer scorer(LeafReaderContext context) throws IOException { final SortedNumericDocValues values = context.reader().getSortedNumericDocValues(field); if (values == null) { return null; } final TwoPhaseIterator iterator = new TwoPhaseIterator(values) { @Override public boolean matches() throws IOException { for (int i = 0, count = values.docValueCount(); i < count; ++i) { final long value = values.nextValue(); final double x = XYEncodingUtils.decode((int) (value >>> 32)); final double y = XYEncodingUtils.decode((int) (value & 0xFFFFFFFF)); if (component2D.contains(x, y)) { return true; } } return false; } @Override public float matchCost() { return 1000f; // TODO: what should it be? } }; return new ConstantScoreScorer(this, boost, scoreMode, iterator); } @Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); } }; }
Example 12
Source File: LatLonDocValuesBoxQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { return new ConstantScoreWeight(this, boost) { @Override public Scorer scorer(LeafReaderContext context) throws IOException { final SortedNumericDocValues values = context.reader().getSortedNumericDocValues(field); if (values == null) { return null; } final TwoPhaseIterator iterator = new TwoPhaseIterator(values) { @Override public boolean matches() throws IOException { for (int i = 0, count = values.docValueCount(); i < count; ++i) { final long value = values.nextValue(); final int lat = (int) (value >>> 32); if (lat < minLatitude || lat > maxLatitude) { // not within latitude range continue; } final int lon = (int) (value & 0xFFFFFFFF); if (crossesDateline) { if (lon > maxLongitude && lon < minLongitude) { // not within longitude range continue; } } else { if (lon < minLongitude || lon > maxLongitude) { // not within longitude range continue; } } return true; } return false; } @Override public float matchCost() { return 5; // 5 comparisons } }; return new ConstantScoreScorer(this, boost, scoreMode, iterator); } @Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, field); } }; }
Example 13
Source File: DistanceValueSource.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, strategy.getFieldNameX(), strategy.getFieldNameY()); }
Example 14
Source File: BBoxValueSource.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, strategy.field_maxX, strategy.field_maxY, strategy.field_minX, strategy.field_minY); }
Example 15
Source File: TermsQParserPlugin.java From lucene-solr with Apache License 2.0 | 4 votes |
public Weight createWeight(IndexSearcher searcher, final ScoreMode scoreMode, float boost) throws IOException { if (! (searcher instanceof SolrIndexSearcher)) { log.debug("Falling back to DocValuesTermsQuery because searcher [{}] is not the required SolrIndexSearcher", searcher); return super.createWeight(searcher, scoreMode, boost); } topLevelDocValues = DocValues.getSortedSet(((SolrIndexSearcher)searcher).getSlowAtomicReader(), fieldName); topLevelTermOrdinals = new LongBitSet(topLevelDocValues.getValueCount()); PrefixCodedTerms.TermIterator iterator = getTerms().iterator(); long lastTermOrdFound = 0; for(BytesRef term = iterator.next(); term != null; term = iterator.next()) { long currentTermOrd = lookupTerm(topLevelDocValues, term, lastTermOrdFound); if (currentTermOrd >= 0L) { matchesAtLeastOneTerm = true; topLevelTermOrdinals.set(currentTermOrd); lastTermOrdFound = currentTermOrd; } } return new ConstantScoreWeight(this, boost) { public Scorer scorer(LeafReaderContext context) throws IOException { if (! matchesAtLeastOneTerm) { return null; } SortedSetDocValues segmentDocValues = context.reader().getSortedSetDocValues(fieldName); if (segmentDocValues == null) { return null; } final int docBase = context.docBase; return new ConstantScoreScorer(this, this.score(), scoreMode, new TwoPhaseIterator(segmentDocValues) { public boolean matches() throws IOException { topLevelDocValues.advanceExact(docBase + approximation.docID()); for(long ord = topLevelDocValues.nextOrd(); ord != -1L; ord = topLevelDocValues.nextOrd()) { if (topLevelTermOrdinals.get(ord)) { return true; } } return false; } public float matchCost() { return 10.0F; } }); } public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, new String[]{fieldName}); } }; }
Example 16
Source File: LatLonPointSpatialField.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public boolean isCacheable(LeafReaderContext ctx) { return DocValues.isCacheable(ctx, fieldName); }