You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example above fetches addresses for users by matching the username in the tuple with the userId field in the addresses collection.
788
788
789
-
== having
790
-
791
-
The `having` expression wraps a stream and applies a boolean operation to each tuple.
792
-
It emits only tuples for which the boolean operation returns *true*.
793
-
794
-
=== having Parameters
795
-
796
-
* `StreamExpression`: (Mandatory) The stream source for the having function.
797
-
* `booleanEvaluator`: (Mandatory) The following boolean operations are supported: `eq` (equals), `gt` (greater than), `lt` (less than), `gteq` (greater than or equal to), `lteq` (less than or equal to), `and`, `or`, `eor` (exclusive or), and `not`.
798
-
Boolean evaluators can be nested with other evaluators to form complex boolean logic.
799
-
800
-
The comparison evaluators compare the value in a specific field with a value, whether a string, number, or boolean.
801
-
For example: `eq(field1, 10)`, returns `true` if `field1` is equal to 10.
802
-
803
-
=== having Syntax
804
-
805
-
[source,text]
806
-
----
807
-
having(rollup(over=a_s,
808
-
sum(a_i),
809
-
search(collection1,
810
-
q="*:*",
811
-
qt="/export",
812
-
fl="id,a_s,a_i,a_f",
813
-
sort="a_s asc")),
814
-
and(gt(sum(a_i), 100), lt(sum(a_i), 110)))
815
-
816
-
----
817
-
818
-
In this example, the `having` expression iterates the aggregated tuples from the `rollup` expression and emits all tuples where the field `sum(a_i)` is greater than 100 and less than 110.
819
-
820
-
== leftOuterJoin
789
+
== fullOuterJoin
821
790
822
-
The `leftOuterJoin` function wraps two streams, Left and Right, and emits tuples from Left.
823
-
If there is a tuple in Right equal (as defined by `on`) then the values in that tuple will be included in the emitted tuple.
824
-
An equal tuple in Right *need not* exist for the Left tuple to be emitted.
825
-
This supports one-to-one, one-to-many, many-to-one, and many-to-many left outer join scenarios.
826
-
The tuples are emitted in the order in which they appear in the Left stream.
791
+
The `fullOuterJoin` function wraps two streams, Left and Right, and emits tuples from both.
792
+
If there is a tuple in Right equal to that in the Left (as defined by `on`) then the values in that tuple will be included in the emitted tuple.
793
+
An equal tuple in one stream *need not* exist for a tuple in the other to be emitted.
794
+
This supports one-to-one, one-to-many, many-to-one, and many-to-many full outer join scenarios.
795
+
The tuples are emitted in the order in which they appear in the streams.
827
796
Both streams must be sorted by the fields being used to determine equality (using the `on` parameter).
828
797
If both tuples contain a field of the same name then the value from the Right stream will be used in the emitted tuple.
829
798
830
799
You can wrap the incoming streams with a `select` function to be specific about which field values are included in the emitted tuple.
831
800
832
-
=== leftOuterJoin Parameters
801
+
=== fullOuterJoin Parameters
833
802
834
803
* `StreamExpression for StreamLeft`
835
804
* `StreamExpression for StreamRight`
836
805
* `on`: Fields to be used for checking equality of tuples between Left and Right.
837
806
Can be of the format `on="fieldName"`, `on="fieldNameInLeft=fieldNameInRight"`, or `on="fieldName, otherFieldName=rightOtherFieldName"`.
=== Reciprocal Rank Fusion (RRF) using fullOuterJoin
836
+
837
+
The `fullOuterJoin` function can be used to construct an RRF algorithm for merging together result sets, as illustrated below.
838
+
839
+
(In a real-world example the two `sort/list/tuple` blocks would likely use `search` instead.)
840
+
841
+
[source,text]
842
+
----
843
+
top(
844
+
n=10,
845
+
sort(
846
+
select(
847
+
fullOuterJoin(
848
+
sort(
849
+
select(
850
+
sort(
851
+
list(
852
+
tuple(id=1, title="L 1", left="a", score=4.5),
853
+
tuple(id=2, title="L 2", left="b", score=3.5),
854
+
tuple(id=3, title="L 3", left="c", score=2.5),
855
+
tuple(id=4, title="L 4", left="d", score=2.5),
856
+
tuple(id=5, title="L 5", left="e", score=2.5),
857
+
tuple(id=6, title="L 6", left="f", score=2.5),
858
+
),
859
+
by="score desc"
860
+
),
861
+
*,
862
+
score as scoreL,
863
+
add(recNum(),1) as rankL,
864
+
div(1,add(rankL,60)) as rrL
865
+
),
866
+
by="id asc"
867
+
),
868
+
sort(
869
+
select(
870
+
sort(
871
+
list(
872
+
tuple(id=3, title="R 3", right="g", score=0.9),
873
+
tuple(id=2, title="R 2", right="h", score=0.8),
874
+
tuple(id=4, title="R 4", right="i", score=0.7),
875
+
tuple(id=7, title="R 7", right="j", score=0.6),
876
+
tuple(id=8, title="R 8", right="k", score=0.5),
877
+
tuple(id=9, title="R 9", right="l", score=0.5),
878
+
),
879
+
by="score desc"
880
+
),
881
+
*,
882
+
score as scoreR,
883
+
add(recNum(),1) as rankR,
884
+
div(1,add(rankR,60)) as rrR
885
+
),
886
+
by="id asc"
887
+
),
888
+
on="id"
889
+
),
890
+
*,
891
+
replace(rrL,null,withValue=0),
892
+
replace(rrR,null,withValue=0),
893
+
add(rrL,rrR) as rrf,
894
+
),
895
+
by="rrf desc"
896
+
),
897
+
sort="rrf desc"
898
+
)
899
+
----
900
+
901
+
== having
902
+
903
+
The `having` expression wraps a stream and applies a boolean operation to each tuple.
904
+
It emits only tuples for which the boolean operation returns *true*.
905
+
906
+
=== having Parameters
907
+
908
+
* `StreamExpression`: (Mandatory) The stream source for the having function.
909
+
* `booleanEvaluator`: (Mandatory) The following boolean operations are supported: `eq` (equals), `gt` (greater than), `lt` (less than), `gteq` (greater than or equal to), `lteq` (less than or equal to), `and`, `or`, `eor` (exclusive or), and `not`.
910
+
Boolean evaluators can be nested with other evaluators to form complex boolean logic.
911
+
912
+
The comparison evaluators compare the value in a specific field with a value, whether a string, number, or boolean.
913
+
For example: `eq(field1, 10)`, returns `true` if `field1` is equal to 10.
914
+
915
+
=== having Syntax
916
+
917
+
[source,text]
918
+
----
919
+
having(rollup(over=a_s,
920
+
sum(a_i),
921
+
search(collection1,
922
+
q="*:*",
923
+
qt="/export",
924
+
fl="id,a_s,a_i,a_f",
925
+
sort="a_s asc")),
926
+
and(gt(sum(a_i), 100), lt(sum(a_i), 110)))
927
+
928
+
----
929
+
930
+
In this example, the `having` expression iterates the aggregated tuples from the `rollup` expression and emits all tuples where the field `sum(a_i)` is greater than 100 and less than 110.
931
+
866
932
== hashJoin
867
933
868
934
The `hashJoin` function wraps two streams, Left and Right, and for every tuple in Left which exists in Right will emit a tuple containing the fields of both tuples.
@@ -986,6 +1052,52 @@ intersect(
986
1052
)
987
1053
----
988
1054
1055
+
== leftOuterJoin
1056
+
1057
+
The `leftOuterJoin` function wraps two streams, Left and Right, and emits tuples from Left.
1058
+
If there is a tuple in Right equal (as defined by `on`) then the values in that tuple will be included in the emitted tuple.
1059
+
An equal tuple in Right *need not* exist for the Left tuple to be emitted.
1060
+
This supports one-to-one, one-to-many, many-to-one, and many-to-many left outer join scenarios.
1061
+
The tuples are emitted in the order in which they appear in the Left stream.
1062
+
Both streams must be sorted by the fields being used to determine equality (using the `on` parameter).
1063
+
If both tuples contain a field of the same name then the value from the Right stream will be used in the emitted tuple.
1064
+
1065
+
You can wrap the incoming streams with a `select` function to be specific about which field values are included in the emitted tuple.
1066
+
1067
+
=== leftOuterJoin Parameters
1068
+
1069
+
* `StreamExpression for StreamLeft`
1070
+
* `StreamExpression for StreamRight`
1071
+
* `on`: Fields to be used for checking equality of tuples between Left and Right.
1072
+
Can be of the format `on="fieldName"`, `on="fieldNameInLeft=fieldNameInRight"`, or `on="fieldName, otherFieldName=rightOtherFieldName"`.
0 commit comments