use of org.apache.solr.client.solrj.io.ops.ReplaceOperation in project lucene-solr by apache.
the class OperationsTest method replaceValueNullWithFloat.
@Test
public void replaceValueNullWithFloat() throws Exception {
Tuple tuple;
StreamOperation operation;
operation = new ReplaceOperation("fieldA", StreamExpressionParser.parse("replace(null, withValue=123.45678)"), factory);
// replace
values.clear();
values.put("fieldB", "bar");
values.put("fieldC", 123);
tuple = new Tuple(values);
operation.operate(tuple);
Assert.assertNotNull(tuple.get("fieldA"));
Assert.assertEquals(123.45678, tuple.get("fieldA"));
// don't replace
values.clear();
values.put("fieldA", "exists");
values.put("fieldB", "bar");
values.put("fieldC", 123);
tuple = new Tuple(values);
operation.operate(tuple);
Assert.assertNotNull(tuple.get("fieldA"));
Assert.assertEquals("exists", tuple.get("fieldA"));
}
use of org.apache.solr.client.solrj.io.ops.ReplaceOperation in project lucene-solr by apache.
the class OperationsTest method replaceFieldNullWithNonExistantField.
@Test
public void replaceFieldNullWithNonExistantField() throws Exception {
Tuple tuple;
StreamOperation operation;
operation = new ReplaceOperation("fieldA", StreamExpressionParser.parse("replace(null, withField=fieldD)"), factory);
// replace
values.clear();
values.put("fieldB", "bar");
values.put("fieldC", 123);
tuple = new Tuple(values);
operation.operate(tuple);
Assert.assertNull(tuple.get("fieldA"));
// don't replace
values.clear();
values.put("fieldA", "exists");
values.put("fieldB", "bar");
values.put("fieldC", 123);
tuple = new Tuple(values);
operation.operate(tuple);
Assert.assertNotNull(tuple.get("fieldA"));
Assert.assertEquals("exists", tuple.get("fieldA"));
}
Aggregations