2727import org .elasticsearch .xpack .esql .core .tree .Source ;
2828
2929import java .io .IOException ;
30+ import java .util .ArrayList ;
3031import java .util .Iterator ;
3132import java .util .List ;
3233import java .util .Objects ;
@@ -124,11 +125,16 @@ public LookupFromIndexOperator(
124125 @ Override
125126 protected void performAsync (Page inputPage , ActionListener <OngoingJoin > listener ) {
126127 Block [] inputBlockArray = new Block [matchFields .size ()];
128+ List <MatchConfig > newMatchFields = new ArrayList <>();
127129 for (int i = 0 ; i < matchFields .size (); i ++) {
128130 MatchConfig matchField = matchFields .get (i );
129131 int inputChannel = matchField .channel ();
130132 final Block inputBlock = inputPage .getBlock (inputChannel );
131133 inputBlockArray [i ] = inputBlock ;
134+ // the matchFields we have are indexed by the input channel on the left side of the join
135+ // create a new MatchConfig that uses the field name and type from the matchField
136+ // but the new channel index in the inputBlockArray
137+ newMatchFields .add (new MatchConfig (matchField .fieldName (), i , matchField .type ()));
132138 }
133139 // we only add to the totalRows once, so we can use the first block
134140 totalRows += inputPage .getBlock (0 ).getTotalValueCount ();
@@ -137,7 +143,7 @@ protected void performAsync(Page inputPage, ActionListener<OngoingJoin> listener
137143 sessionId ,
138144 lookupIndex ,
139145 lookupIndexPattern ,
140- matchFields ,
146+ newMatchFields ,
141147 new Page (inputBlockArray ),
142148 loadFields ,
143149 source
0 commit comments