@@ -597,6 +597,16 @@ public void testLookupJoinIndexForbidden() throws Exception {
597597 assertThat (resp .getMessage (), containsString ("Unknown index [lookup-user1]" ));
598598 assertThat (resp .getResponse ().getStatusLine ().getStatusCode (), equalTo (HttpStatus .SC_BAD_REQUEST ));
599599
600+ resp = expectThrows (
601+ ResponseException .class ,
602+ () -> runESQLCommand (
603+ "metadata1_read2" ,
604+ "FROM lookup-user2 | EVAL value = 10.0 | LOOKUP JOIN `lookup-first-alias` ON value | KEEP x"
605+ )
606+ );
607+ assertThat (resp .getMessage (), containsString ("Unknown index [lookup-first-alias]" ));
608+ assertThat (resp .getResponse ().getStatusLine ().getStatusCode (), equalTo (HttpStatus .SC_BAD_REQUEST ));
609+
600610 resp = expectThrows (
601611 ResponseException .class ,
602612 () -> runESQLCommand ("metadata1_read2" , "ROW x = 10.0 | EVAL value = x | LOOKUP JOIN `lookup-user1` ON value | KEEP x" )
@@ -612,6 +622,20 @@ public void testLookupJoinIndexForbidden() throws Exception {
612622 assertThat (resp .getResponse ().getStatusLine ().getStatusCode (), equalTo (HttpStatus .SC_BAD_REQUEST ));
613623 }
614624
625+ public void testFromLookupIndexForbidden () throws Exception {
626+ var resp = expectThrows (ResponseException .class , () -> runESQLCommand ("metadata1_read2" , "FROM lookup-user1" ));
627+ assertThat (resp .getMessage (), containsString ("Unknown index [lookup-user1]" ));
628+ assertThat (resp .getResponse ().getStatusLine ().getStatusCode (), equalTo (HttpStatus .SC_BAD_REQUEST ));
629+
630+ resp = expectThrows (ResponseException .class , () -> runESQLCommand ("metadata1_read2" , "FROM lookup-first-alias" ));
631+ assertThat (resp .getMessage (), containsString ("Unknown index [lookup-first-alias]" ));
632+ assertThat (resp .getResponse ().getStatusLine ().getStatusCode (), equalTo (HttpStatus .SC_BAD_REQUEST ));
633+
634+ resp = expectThrows (ResponseException .class , () -> runESQLCommand ("alias_user1" , "FROM lookup-user1" ));
635+ assertThat (resp .getMessage (), containsString ("Unknown index [lookup-user1]" ));
636+ assertThat (resp .getResponse ().getStatusLine ().getStatusCode (), equalTo (HttpStatus .SC_BAD_REQUEST ));
637+ }
638+
615639 private void createEnrichPolicy () throws Exception {
616640 createIndex ("songs" , Settings .EMPTY , """
617641 "properties":{"song_id": {"type": "keyword"}, "title": {"type": "keyword"}, "artist": {"type": "keyword"} }
0 commit comments