use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class ElasticWriter method mapToJson.
static Map<String, Object> mapToJson(Document document, boolean detectNumberValues) {
Map<String, Object> jsonDocument = new HashMap<String, Object>();
for (Field field : document.getFields()) {
List<String> values = field.getValues();
if (values == null || values.isEmpty()) {
continue;
}
boolean fieldIsFlat = field.getName().contains(".");
String fieldName = field.getName();
Object fieldValue = field.getValues();
if (values.size() == 1) {
fieldValue = transformDatatype(field.getValue(), detectNumberValues);
}
if (fieldIsFlat) {
fieldValue = createExpandedValue(fieldName, fieldValue);
fieldName = StringUtils.substringBefore(fieldName, ".");
}
jsonDocument.put(fieldName, fieldValue);
}
return jsonDocument;
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class FieldJoiner method document.
@Override
public void document(Document document) {
Map<String, String> documentMap = new HashMap<String, String>();
for (Field field : document.getFields()) {
documentMap.put(field.getName(), field.getValue());
}
StrSubstitutor sub = new StrSubstitutor(documentMap);
String value = sub.replace(output);
document.addField(outputField, value);
super.document(document);
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class StatisticFilter method document.
@Override
public void document(Document document) {
for (Field field : document.getFields()) {
for (Pair<String, String> dynamicField : dynamicFields) {
if (field.getName().matches(dynamicField.getLeft())) {
field.setName(dynamicField.getRight());
}
}
FieldStatistic fieldStatistic = fieldStatisticMap.get(field.getName());
if (fieldStatistic == null) {
fieldStatistic = new FieldStatistic(field.getName());
fieldStatisticMap.put(field.getName(), fieldStatistic);
}
fieldStatistic.maxValueCount(field.getValues().size());
for (String value : field.getValues()) {
fieldStatistic.processValue(value);
}
}
documentCount++;
super.document(document);
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class SystemOutWriter method document.
@Override
public void document(Document document) {
documentCounter++;
List<Field> values = document.getFields();
if (values != null) {
for (Field f : values) {
fieldCounter++;
System.out.print(prefix + "name: " + f.getName());
String out = Joiner.on(", ").skipNulls().join(f.getValues());
System.out.println(prefix + " -- value: " + out);
}
}
super.document(document);
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class AggregationCountFilter method document.
@Override
public void document(Document document) {
for (Field field : document.getFields()) {
AtomicLongMap<String> countMap = aggregation.get(field.getName());
if (countMap == null) {
countMap = AtomicLongMap.create();
}
for (String value : field.getValues()) {
countMap.incrementAndGet(value);
}
aggregation.put(field.getName(), countMap);
}
}
Aggregations