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 ); }
private DocWithId() { idField = new StringField( FIELD_ENTITY_ID, "", YES ); idValueField = new NumericDocValuesField( FIELD_ENTITY_ID, 0L ); document = new Document(); document.add( idField ); document.add( idValueField ); }
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; }
field = new NumericDocValuesField( key, Long.parseLong( value.toString() ) );
/** * 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 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 protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { // see InternalEngine.updateVersion to see where the real version value is set final Field version = new NumericDocValuesField(NAME, -1L); context.version(version); fields.add(version); }
@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))); }
@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))); }
@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))); }
@Override public void initialize() { this.numericDocField = new NumericDocValuesField( FIELD_NAME_INDEXING_METADATA_VALUE_TOMBSTONE_TIME, ACTIVE_DOCUMENT_TOMBSTONE_TIME); } };
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { BytesReference originalSource = context.sourceToParse().source(); BytesReference source = originalSource; if (enabled && fieldType().stored() && source != null) { // Percolate and tv APIs may not set the source and that is ok, because these APIs will not index any data if (filter != null) { // we don't update the context source if we filter, we want to keep it as is... Tuple<XContentType, Map<String, Object>> mapTuple = XContentHelper.convertToMap(source, true, context.sourceToParse().getXContentType()); Map<String, Object> filteredSource = filter.apply(mapTuple.v2()); BytesStreamOutput bStream = new BytesStreamOutput(); XContentType contentType = mapTuple.v1(); XContentBuilder builder = XContentFactory.contentBuilder(contentType, bStream).map(filteredSource); builder.close(); source = bStream.bytes(); } BytesRef ref = source.toBytesRef(); fields.add(new StoredField(fieldType().name(), ref.bytes, ref.offset, ref.length)); } else { source = null; } if (originalSource != null && source != originalSource && context.indexSettings().isSoftDeleteEnabled()) { // if we omitted source or modified it we add the _recovery_source to ensure we have it for ops based recovery BytesRef ref = originalSource.toBytesRef(); fields.add(new StoredField(RECOVERY_SOURCE_NAME, ref.bytes, ref.offset, ref.length)); fields.add(new NumericDocValuesField(RECOVERY_SOURCE_NAME, 1)); } }
public static void fillDocumentID(Document doc, long id) { Field uidField = new NumericDocValuesField(AbstractZoieIndexable.DOCUMENT_ID_PAYLOAD_FIELD, id); doc.add(uidField); }
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { // see InternalEngine.updateVersion to see where the real version value is set final Field version = new NumericDocValuesField(NAME, -1L); context.version(version); fields.add(version); }
@Override protected void onExecute(Document doc, XsObject root, XsObject current, LogicletContext ctx, ExecuteWatcher watcher) { String field = PropertiesConstants.transform(ctx, $field, ""); long value = PropertiesConstants.transform(ctx, $value, 0L); if (StringUtils.isNotEmpty(field)){ doc.add(new NumericDocValuesField(field,value)); if (store){ doc.add(new LongField(field,value,Field.Store.YES)); } } }
@Override public void initialize() { this.storedField = new StoredField(ServiceDocument.FIELD_NAME_EXPIRATION_TIME_MICROS, 0L); this.longPoint = new LongPoint(ServiceDocument.FIELD_NAME_EXPIRATION_TIME_MICROS, 0L); this.numericDocField = new NumericDocValuesField( ServiceDocument.FIELD_NAME_EXPIRATION_TIME_MICROS, 0L); } };
@Test public void testSerializationOfNumericDocValuesField() throws Exception { Document document = new Document(); document.add( new NumericDocValuesField( "foo", 22L ) ); List<LuceneWork> expectedWorkList = buildLuceneWorks( document ); serializeDeserializeAndAssert( expectedWorkList ); }
@Override protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException { if (enabledState.enabled) { long timestamp = context.sourceToParse().timestamp(); if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { fields.add(new LegacyLongFieldMapper.CustomLongNumericField(timestamp, fieldType())); } if (fieldType().hasDocValues()) { fields.add(new NumericDocValuesField(fieldType().name(), timestamp)); } } }
private List<LuceneWork> buildV12Works() throws Exception { List<LuceneWork> works = new ArrayList<>(); Document document = new Document(); document.add( new NumericDocValuesField( "foo", 22L ) ); document.add( new BinaryDocValuesField( "foo", new BytesRef( "world" ) ) ); document.add( new SortedSetDocValuesField( "foo", new BytesRef( "hello" ) ) ); document.add( new SortedDocValuesField( "foo", new BytesRef( "world" ) ) ); works.add( new AddLuceneWork( 123, "123", remoteTypeId, document ) ); return works; }
@Test public void testSerializationOfMultipleDocValuesFields() throws Exception { Document document = new Document(); document.add( new NumericDocValuesField( "foo", 22L ) ); document.add( new BinaryDocValuesField( "foo", new BytesRef( "world" ) ) ); document.add( new SortedSetDocValuesField( "foo", new BytesRef( "hello" ) ) ); document.add( new SortedSetDocValuesField( "foo", new BytesRef( "world" ) ) ); document.add( new SortedDocValuesField( "foo", new BytesRef( "world" ) ) ); List<LuceneWork> expectedWorkList = buildLuceneWorks( document ); serializeDeserializeAndAssert( expectedWorkList ); }