use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class MappingFilter method document.
@Override
public void document(Document document) {
Document mappedDocument;
if (!appendFields) {
mappedDocument = new Document();
} else {
mappedDocument = new Document();
mappedDocument.getFields().addAll(document.getFields());
}
for (Field f : document.getFields()) {
List<String> mappedNameList = mapping.get(f.getName());
if (mappedNameList == null) {
continue;
}
for (String mappedName : mappedNameList) {
List<String> mappedFunctions = mappingFunctions.get(mappedName);
if (!Strings.isNullOrEmpty(mappedName)) {
List<String> newValues = new ArrayList<String>();
for (String value : f.getValues()) {
String newValue = value;
for (String function : mappedFunctions) {
newValue = simpleMapping.executeFunction(function, newValue);
}
newValues.add(newValue);
}
mappedDocument.addField(mappedName, newValues);
Field mappedField = mappedDocument.getField(mappedName);
for (String function : mappedFunctions) {
simpleMapping.executeFieldFunction(function, mappedField);
}
}
}
}
for (Map.Entry<String, String> entry : joins.entrySet()) {
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(entry.getValue());
mappedDocument.addField(entry.getKey(), value);
}
if (mappedDocument.getFields().size() != 0) {
addMissingFields(mappedDocument);
sortFieldsByName(mappedDocument);
super.document(mappedDocument);
}
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class DocumentComparator method compare.
public int compare(Document first, Document second) {
if (first == null && second == null) {
return 0;
}
if (first == null) {
return -1;
}
if (second == null) {
return 1;
}
Field firstField = first.getField(fieldName);
Field secondField = second.getField(fieldName);
if (firstField == null && secondField == null) {
return 0;
}
if (firstField == null) {
return -1;
}
if (secondField == null) {
return 1;
}
String firstFieldValue = firstField.getValue();
String secondFieldValue = secondField.getValue();
if (firstFieldValue == null && secondFieldValue == null) {
return 0;
}
if (firstFieldValue == null) {
return -1;
}
if (secondFieldValue == null) {
return 1;
}
return firstFieldValue.compareTo(secondFieldValue);
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class AbstractBaseTest method assertFiledNotExists.
public void assertFiledNotExists(String name) {
if (outputDocumentList.size() == 0) {
Assert.fail("There is no output document.");
}
Document document = outputDocumentList.get(0);
Field f = document.getField(name);
Assert.assertNull(f);
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class AbstractBaseTest method assertFiledExists.
public void assertFiledExists(String name) {
if (outputDocumentList.size() == 0) {
Assert.fail("There is no output document.");
}
Document document = outputDocumentList.get(0);
Field f = document.getField(name);
Assert.assertNotNull(f);
}
use of de.tblsoft.solr.pipeline.bean.Field in project solr-cmd-utils by tblsoft.
the class CompoundWordFilterTest method testGartentor.
@Test
@Ignore
public void testGartentor() {
configure();
document(DocumentBuilder.document().field("noun", "gartentor").create(), DocumentBuilder.document().field("noun", "garten").create(), DocumentBuilder.document().field("noun", "tor").create());
Field d = outputDocumentList.get(0).getField("tokenized");
assertFiledList("tokenized", "garten", "tor");
}
Aggregations