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 enhance( Document document ) { document.add( new StringField( LuceneExplicitIndex.KEY_START_NODE_ID, "" + startNode, Store.YES ) ); document.add( new StringField( LuceneExplicitIndex.KEY_END_NODE_ID, "" + endNode, Store.YES ) ); } }
@Override void removeFieldFromDocument( Document document, String name ) { document.removeFields( name ); }
private static void insertRandomDocuments( IndexWriter writer ) throws IOException { Document doc = new Document(); doc.add( new StringField( "a", "b", Field.Store.YES ) ); doc.add( new StringField( "c", "d", Field.Store.NO ) ); writer.addDocument( doc ); writer.commit(); }
private static Document createDocument( String value ) { Document document = new Document(); document.add( new StoredField( "value", value ) ); return document; } }
/** * Add a field to store document lines-of-code. * @param doc the target document * @param value the loc */ protected void addLOC(Document doc, int value) { doc.add(new StoredField(QueryBuilder.LOC, value)); }
static long getNodeId( Document from ) { String entityId = from.get( FIELD_ENTITY_ID ); return Long.parseLong( entityId ); }
private static Field stringField( String identifier, String value ) { return new StringField( identifier, value, NO ); } }
private static IndexableField[] getDocumentFields( Document document, String name ) { return document.getFields( name ); } }
@Override Field encodeField( String name, Value value ) { return new DoubleField( name, Values.coerceToDouble(value), NO ); }
@Override public FeatureFunction rewrite(IndexReader reader) throws IOException { if (pivot != null) { return super.rewrite(reader); } float newPivot = computePivotFeatureValue(reader, field, feature); return new SaturationFunction(field, feature, newPivot); }
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; }
private static Document newDocument() { Document doc = new Document(); doc.add( new StringField( "test", UUID.randomUUID().toString(), Field.Store.YES ) ); return doc; } }
@Override protected void addNewFieldToDocument( Document document, String key, Object value ) { document.add( new StringField( exactKey( key ), value.toString(), Store.YES ) ); document.add( instantiateField( key, value, TextField.TYPE_STORED ) ); document.add( instantiateSortField( key, value ) ); }
/** * Add a field to store document number of lines. * @param doc the target document * @param value the number of lines */ protected void addNumLines(Document doc, int value) { doc.add(new StoredField(QueryBuilder.NUML, value)); }
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 ); }
private static Document randomDocument() { Document doc = new Document(); doc.add( new StringField( "field", RandomStringUtils.randomNumeric( 5 ), Field.Store.YES ) ); return doc; } }