/** * 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)); }
/** * 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)); }
@Override public void doubleField(FieldInfo fieldInfo, double value) { doc.add(new StoredField(fieldInfo.name, value)); }
@Override public void longField(FieldInfo fieldInfo, long value) { doc.add(new StoredField(fieldInfo.name, value)); }
@Override public void intField(FieldInfo fieldInfo, int value) { doc.add(new StoredField(fieldInfo.name, value)); }
@Override public void binaryField(FieldInfo fieldInfo, byte[] value) throws IOException { doc.add(new StoredField(fieldInfo.name, value)); }
@Override public void floatField(FieldInfo fieldInfo, float value) { doc.add(new StoredField(fieldInfo.name, value)); }
private static Document createDocument( String value ) { Document document = new Document(); document.add( new StoredField( "value", value ) ); return document; } }
/** * Writes a document to contain the serialized version of {@code settings}, * with a {@link QueryBuilder#OBJUID} value set to * {@link #INDEX_ANALYSIS_SETTINGS_OBJUID}. An existing version of the * document is first deleted. * @param writer a defined, target instance * @param settings a defined instance * @throws IOException if I/O error occurs while writing Lucene */ public void write(IndexWriter writer, IndexAnalysisSettings settings) throws IOException { byte[] objser = settings.serialize(); writer.deleteDocuments(new Term(QueryBuilder.OBJUID, INDEX_ANALYSIS_SETTINGS_OBJUID)); Document doc = new Document(); StringField uidfield = new StringField(QueryBuilder.OBJUID, INDEX_ANALYSIS_SETTINGS_OBJUID, Field.Store.NO); doc.add(uidfield); doc.add(new StoredField(QueryBuilder.OBJSER, objser)); doc.add(new StoredField(QueryBuilder.OBJVER, INDEX_ANALYSIS_SETTINGS_OBJVER)); writer.addDocument(doc); }
@Override public void stringField(FieldInfo fieldInfo, byte[] value) throws IOException { final FieldType ft = new FieldType(TextField.TYPE_STORED); ft.setStoreTermVectors(fieldInfo.hasVectors()); ft.setOmitNorms(fieldInfo.omitsNorms()); ft.setIndexOptions(fieldInfo.getIndexOptions()); doc.add(new StoredField(fieldInfo.name, new String(value, StandardCharsets.UTF_8), ft)); }
doc.add(new StoredField(VAL_FIELD_NAME, v.valueBytes(coctx))); doc.add(new StoredField(VER_FIELD_NAME, ver.toString().getBytes()));
document.add( new StoredField( TX_STATE_KEY, TX_STATE_VALUE ) ); cachedDocuments.put( id, document ); add = true;
doc.add(ref); byte[] tags = defs.serialize(); doc.add(new StoredField(QueryBuilder.TAGS, tags)); if (scopes.size() > 0) { byte[] scopesSerialized = scopes.serialize(); doc.add(new StoredField(QueryBuilder.SCOPES, scopesSerialized));
/** * Overwrite this method if you want to filter the input, apply hashing, etc. * * @param feature the current feature. * @param document the current document. * @param featureFieldName the field hashFunctionsFileName of the feature. */ protected void addToDocument(GlobalFeature feature, Document document, String featureFieldName) { document.add(new StoredField(featureFieldName, feature.getByteArrayRepresentation())); }
/** * Overwrite this method if you want to filter the input, apply hashing, etc. * * @param feature the current feature. * @param document the current document. * @param featureFieldName the field hashFunctionsFileName of the feature. */ protected void addToDocument(GlobalFeature feature, Document document, String featureFieldName) { document.add(new StoredField(featureFieldName, feature.getByteArrayRepresentation())); }
@Override public List<Field> createFields(String name, Number value, boolean indexed, boolean docValued, boolean stored) { List<Field> fields = new ArrayList<>(); if (indexed) { fields.add(new IntPoint(name, value.intValue())); } if (docValued) { fields.add(new SortedNumericDocValuesField(name, value.intValue())); } if (stored) { fields.add(new StoredField(name, value.intValue())); } return fields; } },
@Override public List<Field> createFields(String name, Number value, boolean indexed, boolean docValued, boolean stored) { List<Field> fields = new ArrayList<>(); if (indexed) { fields.add(new LongPoint(name, value.longValue())); } if (docValued) { fields.add(new SortedNumericDocValuesField(name, value.longValue())); } if (stored) { fields.add(new StoredField(name, value.longValue())); } return fields; } };
@Override public List<Field> createFields(String name, Number value, boolean indexed, boolean docValued, boolean stored) { List<Field> fields = new ArrayList<>(); if (indexed) { fields.add(new DoublePoint(name, value.doubleValue())); } if (docValued) { fields.add(new SortedNumericDocValuesField(name, NumericUtils.doubleToSortableLong(value.doubleValue()))); } if (stored) { fields.add(new StoredField(name, value.doubleValue())); } return fields; }
@Override public List<Field> createFields(String name, Number value, boolean indexed, boolean docValued, boolean stored) { List<Field> fields = new ArrayList<>(); if (indexed) { fields.add(new FloatPoint(name, value.floatValue())); } if (docValued) { fields.add(new SortedNumericDocValuesField(name, NumericUtils.floatToSortableInt(value.floatValue()))); } if (stored) { fields.add(new StoredField(name, value.floatValue())); } return fields; }
public ParsedDocument createNoopTombstoneDoc(String index, String reason) throws MapperParsingException { final String id = ""; // _id won't be used. final SourceToParse sourceToParse = SourceToParse.source(index, type, id, new BytesArray("{}"), XContentType.JSON); final ParsedDocument parsedDoc = documentParser.parseDocument(sourceToParse, noopTombstoneMetadataFieldMappers).toTombstone(); // Store the reason of a noop as a raw string in the _source field final BytesRef byteRef = new BytesRef(reason); parsedDoc.rootDoc().add(new StoredField(SourceFieldMapper.NAME, byteRef.bytes, byteRef.offset, byteRef.length)); return parsedDoc; }