use of org.apache.solr.client.solrj.io.ops.ReplaceOperation in project lucene-solr by apache.
the class OperationsTest method replaceFieldNullWithString.
@Test
public void replaceFieldNullWithString() throws Exception {
Tuple tuple;
StreamOperation operation;
operation = new ReplaceOperation("fieldA", StreamExpressionParser.parse("replace(null, withField=fieldB)"), 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("bar", 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 replaceValueNullWithInt.
@Test
public void replaceValueNullWithInt() throws Exception {
Tuple tuple;
StreamOperation operation;
operation = new ReplaceOperation("fieldA", StreamExpressionParser.parse("replace(null, withValue=123)"), factory);
// replace
values.clear();
values.put("fieldB", "bar");
values.put("fieldC", (long) 123);
tuple = new Tuple(values);
operation.operate(tuple);
Assert.assertNotNull(tuple.get("fieldA"));
Assert.assertEquals((long) 123, 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 replaceValueNullWithDouble.
@Test
public void replaceValueNullWithDouble() throws Exception {
Tuple tuple;
StreamOperation operation;
operation = new ReplaceOperation("fieldA", StreamExpressionParser.parse("replace(null, withValue=123.45678912345)"), 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.45678912345, 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 replaceFieldNullWithInt.
@Test
public void replaceFieldNullWithInt() throws Exception {
Tuple tuple;
StreamOperation operation;
operation = new ReplaceOperation("fieldA", StreamExpressionParser.parse("replace(null, withField=fieldC)"), 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, 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 replaceValueNullWithString.
@Test
public void replaceValueNullWithString() throws Exception {
Tuple tuple;
StreamOperation operation;
operation = new ReplaceOperation("fieldA", StreamExpressionParser.parse("replace(null, withValue=foo)"), 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("foo", 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