private DocWithId() { idField = new StringField( NODE_ID_KEY, "", YES ); idValueField = new NumericDocValuesField( NODE_ID_KEY, 0L ); document = new Document(); document.add( idField ); document.add( idValueField ); }
@Override public void setDoubleValue(double value) { super.setLongValue(Double.doubleToRawLongBits(value)); }
/** * Create a query for matching an exact long value. * <p><b>NOTE</b>: Such queries cannot efficiently advance to the next match, * which makes them slow if they are not ANDed with a selective query. As a * consequence, they are best used wrapped in an {@link IndexOrDocValuesQuery}, * alongside a range query that executes on points, such as * {@link LongPoint#newExactQuery}. */ public static Query newSlowExactQuery(String field, long value) { return newSlowRangeQuery(field, value, value); } }
/** Build the example index. */ public void index() throws IOException { IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig( new WhitespaceAnalyzer()).setOpenMode(OpenMode.CREATE)); // Add documents with a fake timestamp, 1000 sec before // "now", 2000 sec before "now", ...: for(int i=0;i<100;i++) { Document doc = new Document(); long then = nowSec - i * 1000; // Add as doc values field, so we can compute range facets: doc.add(new NumericDocValuesField("timestamp", then)); // Add as numeric field so we can drill-down: doc.add(new LongPoint("timestamp", then)); indexWriter.addDocument(doc); } // Open near-real-time searcher searcher = new IndexSearcher(DirectoryReader.open(indexWriter)); indexWriter.close(); }
@Override public void addFields(final String name, final Object value, final ViewSettings settings, final Document to) throws ParseException { to.add(boost(new LongPoint(name, toDate(value)), settings)); to.add(new NumericDocValuesField(name, toDate(value))); }
); Document dummy = new Document(); fieldBridge.set( "dummy", ); field = dummy.getField( "dummy" ); field = document.getField( sortField.getAbsoluteName() ); document.add( new NumericDocValuesField( sortField.getAbsoluteName(), numericValue.longValue() ) );
void addTombstoneTimeField() { this.tombstoneTimeField.numericDocField.setLongValue(ACTIVE_DOCUMENT_TOMBSTONE_TIME); this.doc.add(this.tombstoneTimeField.numericDocField); }
field = new NumericDocValuesField( key, Long.parseLong( value.toString() ) );
private NumericDocValuesField getAndSetNumericField(String propertyName, long propertyValue, boolean isCollectionItem) { if (isCollectionItem) { return new NumericDocValuesField(propertyName, propertyValue); } NumericDocValuesField ndField = this.numericFields.computeIfAbsent(propertyName, (k) -> { return new NumericDocValuesField(propertyName, propertyValue); }); ndField.setLongValue(propertyValue); return ndField; }
if (!queryOptions.contains(QueryOption.INCLUDE_ALL_VERSIONS) && !queryOptions.contains(QueryOption.TIME_SNAPSHOT)) { Query currentClause = NumericDocValuesField.newSlowExactQuery( LuceneIndexDocumentHelper.FIELD_NAME_INDEXING_METADATA_VALUE_TOMBSTONE_TIME, LuceneIndexDocumentHelper.ACTIVE_DOCUMENT_TOMBSTONE_TIME); Query tombstoneClause = NumericDocValuesField.newSlowRangeQuery( LuceneIndexDocumentHelper.FIELD_NAME_INDEXING_METADATA_VALUE_TOMBSTONE_TIME, qs.timeSnapshotBoundaryMicros, LuceneIndexDocumentHelper.ACTIVE_DOCUMENT_TOMBSTONE_TIME);
IndexWriter writer = new IndexWriter(indexDir, new IndexWriterConfig( new WhitespaceAnalyzer()).setOpenMode(OpenMode.CREATE)); Document doc = new Document(); doc.add(new DoublePoint("latitude", 40.759011)); doc.add(new NumericDocValuesField("latitude", Double.doubleToRawLongBits(40.759011))); doc.add(new DoublePoint("longitude", -73.9844722)); doc.add(new NumericDocValuesField("longitude", Double.doubleToRawLongBits(-73.9844722))); writer.addDocument(doc); doc = new Document(); doc.add(new DoublePoint("latitude", 40.718266)); doc.add(new NumericDocValuesField("latitude", Double.doubleToRawLongBits(40.718266))); doc.add(new DoublePoint("longitude", -74.007819)); doc.add(new NumericDocValuesField("longitude", Double.doubleToRawLongBits(-74.007819))); writer.addDocument(doc); doc = new Document(); doc.add(new DoublePoint("latitude", 40.7051157)); doc.add(new NumericDocValuesField("latitude", Double.doubleToRawLongBits(40.7051157))); doc.add(new DoublePoint("longitude", -74.0088305)); doc.add(new NumericDocValuesField("longitude", Double.doubleToRawLongBits(-74.0088305))); writer.addDocument(doc); searcher = new IndexSearcher(DirectoryReader.open(writer)); writer.close();
@Override public void addFields(final String name, final Object value, final ViewSettings settings, final Document to) { to.add(boost(new IntPoint(name, toInt(value)), settings)); to.add(new NumericDocValuesField(name, toInt(value))); }
); Document dummy = new Document(); fieldBridge.set( "dummy", ); field = dummy.getField( "dummy" ); field = document.getField( sortField.getAbsoluteName() ); document.add( new NumericDocValuesField( sortField.getAbsoluteName(), numericValue.longValue() ) );
private void updateLongFieldContext(long value, LongFieldContext ctx) { ctx.storedField.setLongValue(value); this.doc.add(ctx.storedField); ctx.longPoint.setLongValue(value); this.doc.add(ctx.longPoint); ctx.numericDocField.setLongValue(value); this.doc.add(ctx.numericDocField); }
/** * Returns a numeric docvalues which can be used to soft-delete documents. */ public static NumericDocValuesField newSoftDeletesField() { return new NumericDocValuesField(SOFT_DELETES_FIELD, 1); }
public static Document newBaseDocument( long entityId ) { Document doc = new Document(); doc.add( new StringField( LuceneExplicitIndex.KEY_DOC_ID, "" + entityId, Store.YES ) ); doc.add( new NumericDocValuesField( LuceneExplicitIndex.KEY_DOC_ID, entityId ) ); return doc; }
/** Build the example index. */ private void index() throws IOException { IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig( new WhitespaceAnalyzer()).setOpenMode(OpenMode.CREATE)); // Writes facet ords to a separate directory from the main index DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir); Document doc = new Document(); doc.add(new TextField("c", "foo bar", Store.NO)); doc.add(new NumericDocValuesField("popularity", 5L)); doc.add(new FacetField("A", "B")); indexWriter.addDocument(config.build(taxoWriter, doc)); doc = new Document(); doc.add(new TextField("c", "foo foo bar", Store.NO)); doc.add(new NumericDocValuesField("popularity", 3L)); doc.add(new FacetField("A", "C")); indexWriter.addDocument(config.build(taxoWriter, doc)); indexWriter.close(); taxoWriter.close(); }
@Override public void addFields(final String name, final Object value, final ViewSettings settings, final Document to) { to.add(boost(new LongPoint(name, toLong(value)), settings)); to.add(new NumericDocValuesField(name, toLong(value))); }
public static SequenceIDFields emptySeqID() { return new SequenceIDFields(new LongPoint(NAME, SequenceNumbers.UNASSIGNED_SEQ_NO), new NumericDocValuesField(NAME, SequenceNumbers.UNASSIGNED_SEQ_NO), new NumericDocValuesField(PRIMARY_TERM_NAME, 0), new NumericDocValuesField(TOMBSTONE_NAME, 0)); } }
@Override public void setFloatValue(float value) { super.setLongValue(Float.floatToRawIntBits(value)); }