use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class BlacklistFieldFilter method document.
@Override
public void document(Document document) {
Document newDocument = new Document();
for (Field field : document.getFields()) {
if (fields == null || fields.contains(field.getName())) {
List<String> newValues = new ArrayList<String>();
for (String value : field.getValues()) {
if (!topicValues.get(topic).contains(value)) {
newValues.add(value);
}
}
newDocument.setField(field.getName(), newValues);
} else {
newDocument.setField(field.getName(), field.getValues());
}
}
super.document(newDocument);
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class BlacklistTopicFilter method document.
@Override
public void document(Document document) {
boolean blacklist = false;
Field topic = document.getField(fieldTopic);
Field value = document.getField(fieldValue);
if (topic != null && value != null) {
if (topicValues.containsKey(topic.getValue())) {
blacklist = topicValues.get(topic.getValue()).contains(value.getValue().toLowerCase());
}
}
if (!blacklist) {
super.document(document);
}
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class TopicMergeFilter method mergeDocuments.
protected Document mergeDocuments(Document doc1, Document doc2) {
Map<String, HashSet<String>> mergedFields = new HashMap<String, HashSet<String>>();
for (Field field : doc1.getFields()) {
if (field.getValues() != null) {
mergedFields.put(field.getName(), new HashSet<String>(field.getValues()));
}
}
for (Field field : doc2.getFields()) {
if (mergedFields.containsKey(field.getName())) {
if (field.getValues() != null) {
mergedFields.get(field.getName()).addAll(field.getValues());
}
}
}
Document mergedDoc = new Document();
for (Map.Entry<String, HashSet<String>> entry : mergedFields.entrySet()) {
Field mergedField = new Field(entry.getKey(), new ArrayList<String>(entry.getValue()));
mergedDoc.addField(mergedField);
}
return mergedDoc;
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class KeyValueSplitterFilter method processKeyValue.
Field processKeyValue(String keyValue) {
if (Strings.isNullOrEmpty(keyValue)) {
return null;
}
String[] splittedValue = keyValue.split(Pattern.quote(keyValueDelimiter));
if (splittedValue.length != 2) {
return null;
}
String key = keyPrefix + splittedValue[0];
if (normalizeKey) {
key = DocumentUtils.normalizeFieldKey(key);
}
Field field = new Field(key, splittedValue[1]);
return field;
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class KeyValueSplitterFilter method document.
@Override
public void document(Document document) {
List<String> values = document.getFieldValues(fieldName, new ArrayList<String>());
for (String value : values) {
String[] splittedValues = value.split(Pattern.quote(delimiter));
for (String splittedValue : splittedValues) {
Field field = processKeyValue(splittedValue);
if (field != null) {
document.addField(field);
}
}
}
super.document(document);
}
Aggregations