org.apache.solr.client.solrj.io.ops

## Class ReplaceOperation

- java.lang.Object
- - org.apache.solr.client.solrj.io.ops.ReplaceOperation

- All Implemented Interfaces:
    Serializable, StreamOperation, Expressible

      public class ReplaceOperation
      extends Object
      implements StreamOperation

  Replaces some tuple value with another. The replacement value can be either a given value or the value of another field in the tuple. The expression for a replace operation can be of multiple forms: replace(fieldA, 0, withValue=100) // for fieldA if equals 0 then set to 100 replace(fieldA, null, withValue=0) // for fieldA if null then set to 0 replace(fieldA, null, withField=fieldB) // for fieldA if null then set to the value of fieldB (if fieldB is null then fieldA will end up as null) replace(fieldA, 0, withField=fieldB) // for fieldA if 0 then set to the value of fieldB (if fieldB is 0 then fieldA will end up as 0) replace(fieldA, "Izzy and Kayden", withValue="my kids") You can also construct these without the field name in the expression but that does require that you provide the field name during construction. This is most useful during metric calculation because when calculating a metric you have already provided a field name in the metric so there is no reason to have to provide the field name again in the operation sum(fieldA, replace(null, withValue=0)) // performs the replacement on fieldA Equality is determined by the standard type .equals() functions.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReplaceOperation(StreamExpression expression, StreamFactory factory)`
    `ReplaceOperation(String forField, StreamExpression expression, StreamFactory factory)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `operate(Tuple tuple)`
    `Explanation` | `toExplanation(StreamFactory factory)` Returns an explanation about the stream object
    `StreamExpressionParameter` | `toExpression(StreamFactory factory)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ReplaceOperation

          public ReplaceOperation(StreamExpression expression,
                                  StreamFactory factory)
                           throws IOException

      Throws:
        `IOException`

    - #### ReplaceOperation

          public ReplaceOperation(String forField,
                                  StreamExpression expression,
                                  StreamFactory factory)
                           throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### operate

          public void operate(Tuple tuple)

      Specified by:
        `operate` in interface `StreamOperation`

    - #### toExpression

          public StreamExpressionParameter toExpression(StreamFactory factory)
                                                 throws IOException

      Specified by:
        `toExpression` in interface `Expressible`
      Throws:
        `IOException`

    - #### toExplanation

          public Explanation toExplanation(StreamFactory factory)
                                    throws IOException

      Description copied from interface: `Expressible`
      Returns an explanation about the stream object
      Specified by:
        `toExplanation` in interface `Expressible`
      Parameters:
        `factory` - Stream factory for this, contains information about the function name
      Returns:
        Explanation about this stream object containing explanations of any child stream objects
      Throws:
        `IOException` - throw on any error

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.