List of usage examples for org.apache.lucene.index DocValues getSortedNumeric
public static SortedNumericDocValues getSortedNumeric(LeafReader reader, String field) throws IOException
From source file:io.crate.expression.reference.doc.lucene.BooleanColumnReference.java
License:Apache License
@Override public void setNextReader(LeafReaderContext context) throws IOException { super.setNextReader(context); values = FieldData.toString(DocValues.getSortedNumeric(context.reader(), columnName)); }
From source file:io.crate.expression.reference.doc.lucene.ByteColumnReference.java
License:Apache License
@Override public void setNextReader(LeafReaderContext context) throws IOException { super.setNextReader(context); values = DocValues.getSortedNumeric(context.reader(), columnName); }
From source file:org.apache.solr.analytics.function.field.DoubleMultiPointField.java
License:Apache License
@Override public void doSetNextReader(LeafReaderContext context) throws IOException { docValues = DocValues.getSortedNumeric(context.reader(), fieldName); }
From source file:org.apache.solr.handler.component.SortedDateStatsValues.java
License:Apache License
@Override public void setNextReader(LeafReaderContext ctx) throws IOException { sndv = DocValues.getSortedNumeric(ctx.reader(), fieldName); assert sndv != null; }
From source file:org.apache.solr.schema.TestPointFields.java
License:Apache License
private void doTestInternals(String field, String[] values) throws IOException { assertTrue(h.getCore().getLatestSchema().getField(field).getType() instanceof PointField); for (int i = 0; i < 10; i++) { assertU(adoc("id", String.valueOf(i), field, values[i])); }//from w w w .j a v a 2s . c om assertU(commit()); IndexReader ir; RefCounted<SolrIndexSearcher> ref = null; SchemaField sf = h.getCore().getLatestSchema().getField(field); boolean ignoredField = !(sf.indexed() || sf.stored() || sf.hasDocValues()); try { ref = h.getCore().getSearcher(); SolrIndexSearcher searcher = ref.get(); ir = searcher.getIndexReader(); // our own SlowCompositeReader to check DocValues on disk w/o the UninvertingReader added by SolrIndexSearcher final LeafReader leafReaderForCheckingDVs = SlowCompositeReaderWrapper.wrap(searcher.getRawReader()); if (sf.indexed()) { assertEquals("Field " + field + " should have point values", 10, PointValues.size(ir, field)); } else { assertEquals("Field " + field + " should have no point values", 0, PointValues.size(ir, field)); } if (ignoredField) { assertTrue("Field " + field + " should not have docValues", DocValues.getSortedNumeric(leafReaderForCheckingDVs, field) .nextDoc() == DocIdSetIterator.NO_MORE_DOCS); assertTrue("Field " + field + " should not have docValues", DocValues .getNumeric(leafReaderForCheckingDVs, field).nextDoc() == DocIdSetIterator.NO_MORE_DOCS); assertTrue("Field " + field + " should not have docValues", DocValues .getSorted(leafReaderForCheckingDVs, field).nextDoc() == DocIdSetIterator.NO_MORE_DOCS); assertTrue("Field " + field + " should not have docValues", DocValues .getBinary(leafReaderForCheckingDVs, field).nextDoc() == DocIdSetIterator.NO_MORE_DOCS); } else { if (sf.hasDocValues()) { if (sf.multiValued()) { assertFalse("Field " + field + " should have docValues", DocValues.getSortedNumeric(leafReaderForCheckingDVs, field) .nextDoc() == DocIdSetIterator.NO_MORE_DOCS); } else { assertFalse("Field " + field + " should have docValues", DocValues.getNumeric(leafReaderForCheckingDVs, field) .nextDoc() == DocIdSetIterator.NO_MORE_DOCS); } } else { expectThrows(IllegalStateException.class, () -> DocValues.getSortedNumeric(leafReaderForCheckingDVs, field)); expectThrows(IllegalStateException.class, () -> DocValues.getNumeric(leafReaderForCheckingDVs, field)); } expectThrows(IllegalStateException.class, () -> DocValues.getSorted(leafReaderForCheckingDVs, field)); expectThrows(IllegalStateException.class, () -> DocValues.getBinary(leafReaderForCheckingDVs, field)); } for (LeafReaderContext leave : ir.leaves()) { LeafReader reader = leave.reader(); for (int i = 0; i < reader.numDocs(); i++) { Document doc = reader.document(i); if (sf.stored()) { assertNotNull("Field " + field + " not found. Doc: " + doc, doc.get(field)); } else { assertNull(doc.get(field)); } } } } finally { ref.decref(); } clearIndex(); assertU(commit()); }
From source file:org.apache.solr.search.join.GraphPointsCollector.java
License:Apache License
@Override public void doSetNextReader(LeafReaderContext context) throws IOException { super.doSetNextReader(context); values = DocValues.getSortedNumeric(context.reader(), collectField.getName()); }
From source file:org.codelibs.elasticsearch.search.slice.DocValuesSliceQuery.java
License:Apache License
@Override public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException { return new RandomAccessWeight(this) { @Override/*from ww w .ja v a2 s . c o m*/ 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(); } }; } }; }
From source file:org.elasticsearch.index.mapper.ip.LegacyIpIndexFieldData.java
License:Apache License
@Override public AtomicFieldData load(LeafReaderContext context) { return new AtomicFieldData() { @Override/*from w w w. j a v a2s.c o m*/ public void close() { // no-op } @Override public long ramBytesUsed() { return 0; } @Override public ScriptDocValues<?> getScriptValues() { throw new UnsupportedOperationException("Cannot run scripts on ip fields"); } @Override public SortedBinaryDocValues getBytesValues() { SortedNumericDocValues values; try { values = DocValues.getSortedNumeric(context.reader(), fieldName); } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } return new SortedBinaryDocValues() { final ByteBuffer scratch = ByteBuffer.allocate(4); @Override public BytesRef valueAt(int index) { // we do not need to reorder ip addresses since both the numeric // encoding of LegacyIpFieldMapper and the binary encoding of // IpFieldMapper match the sort order of ip addresses long ip = values.valueAt(index); scratch.putInt(0, (int) ip); InetAddress inet; try { inet = InetAddress.getByAddress(scratch.array()); } catch (UnknownHostException e) { throw new IllegalStateException("Cannot happen", e); } byte[] encoded = InetAddressPoint.encode(inet); return new BytesRef(encoded); } @Override public void setDocument(int docId) { values.setDocument(docId); } @Override public int count() { return values.count(); } }; } }; }
From source file:org.elasticsearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder.java
License:Apache License
private static boolean isSingleValued(IndexReader reader, SortField field) throws IOException { SortField.Type type = IndexSortConfig.getSortFieldType(field); for (LeafReaderContext context : reader.leaves()) { if (type == SortField.Type.STRING) { final SortedSetDocValues values = DocValues.getSortedSet(context.reader(), field.getField()); if (values.cost() > 0 && DocValues.unwrapSingleton(values) == null) { return false; }/*from ww w.j a v a 2s . c o m*/ } else { final SortedNumericDocValues values = DocValues.getSortedNumeric(context.reader(), field.getField()); if (values.cost() > 0 && DocValues.unwrapSingleton(values) == null) { return false; } } } return true; }