@Override public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException { return new RandomAccessWeight(this) { @Override protected Bits getMatchingDocs(final LeafReaderContext context) throws IOException { final SortedNumericDocValues values = DocValues.getSortedNumeric(context.reader(), getField()); return new Bits() { @Override public boolean get(int doc) { values.setDocument(doc); for (int i = 0; i < values.count(); i++) { return contains(BitMixer.mix(values.valueAt(i))); } return contains(0); } @Override public int length() { return context.reader().maxDoc(); } }; } }; }
@Override public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException { return new RandomAccessWeight(this) { @Override protected Bits getMatchingDocs(LeafReaderContext context) throws IOException { final int maxDoc = context.reader().maxDoc(); final MultiGeoPointValues values = indexFieldData.load(context).getGeoPointValues(); // checks to see if bounding box crosses 180 degrees if (topLeft.lon() > bottomRight.lon()) { return new Meridian180GeoBoundingBoxBits(maxDoc, values, topLeft, bottomRight); } else { return new GeoBoundingBoxBits(maxDoc, values, topLeft, bottomRight); } } }; }
@Override public Weight createWeight(IndexSearcher searcher, boolean needsScores) { return new RandomAccessWeight(this) { @Override protected Bits getMatchingDocs(LeafReaderContext context) throws IOException { final int maxDoc = context.reader().maxDoc(); return new Bits() { @Override public boolean get(int index) { return match(index); } @Override public int length() { return maxDoc; } }; } }; }
@Override public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException { return new RandomAccessWeight(this) { @Override protected Bits getMatchingDocs(final LeafReaderContext context) throws IOException { final LeafSearchScript leafScript = searchScript.getLeafSearchScript(context); return new Bits() { @Override public boolean get(int doc) { leafScript.setDocument(doc); Object val = leafScript.run(); if (val == null) { return false; } if (val instanceof Boolean) { return (Boolean) val; } if (val instanceof Number) { return ((Number) val).longValue() != 0; } throw new IllegalArgumentException("Can't handle type [" + val + "] in script filter"); } @Override public int length() { return context.reader().maxDoc(); } }; } }; }