public void transform(SolrDocument doc, int docId) { String oldValue = doc.getFieldValue(fieldName); doc.put(newField,getNewValue(oldValue)); }
doc.put(counter + "_" + ChronixQueryParams.FUNCTION + "_" + chronixTransformation.getQueryName(), chronixTransformation.getArguments()); counter++; ChronixAggregation chronixAggregation = functionCtx.getAggregation(aggregation); double value = functionCtx.getAggregationValue(aggregation); doc.put(counter + "_" + ChronixQueryParams.FUNCTION + "_" + chronixAggregation.getQueryName(), value); doc.put(counter + "_" + ChronixQueryParams.FUNCTION_ARGUMENTS + "_" + chronixAggregation.getQueryName(), chronixAggregation.getArguments()); doc.put(counter + "_" + ChronixQueryParams.FUNCTION + nameWithLeadingUnderscore, value); doc.put(counter + "_" + ChronixQueryParams.FUNCTION_ARGUMENTS + nameWithLeadingUnderscore, chronixAnalysis.getArguments());
private SolrDocument solrDocumentWithOutTimeSeriesFunctionResults(boolean dataShouldReturned, boolean dataAsJson, ChronixTimeSeries timeSeries) { SolrDocument doc = new SolrDocument(); //add the join key doc.put(ChronixQueryParams.JOIN_KEY, timeSeries.getJoinKey()); for (Map.Entry<String, Object> entry : (Set<Map.Entry<String, Object>>) timeSeries.getAttributes().entrySet()) { doc.addField(entry.getKey(), entry.getValue()); } //add the metric field as it is not stored in the getAttributes doc.addField(Schema.NAME, timeSeries.getName()); doc.addField(Schema.TYPE, timeSeries.getType()); //TODO: Fix this. It is expensive to calculate this based on the points. This is already stored. doc.addField(Schema.START, timeSeries.getStart()); doc.addField(Schema.END, timeSeries.getEnd()); if (dataShouldReturned) { //ensure that the returned data is sorted timeSeries.sort(); //data should returned serialized as json if (dataAsJson) { doc.setField(ChronixQueryParams.DATA_AS_JSON, timeSeries.dataAsJson()); } else { doc.addField(Schema.DATA, timeSeries.dataAsBlob()); } } return doc; }