IndexOutOfBoundsException


#1

Hi,

When I run the following graql schema defined below

define

#entity

“movie” sub entity has title has instance-id
plays screenedAt
plays hasRuntime;
“showtime” sub entity has date;
“genre” sub entity has category
plays hasCategory;
“theater” sub entity has name
plays screens
plays hasRuntime;

#attribute

“instance-id” sub attribute datatype string;
“title” sub attribute datatype string;
“category” sub attribute datatype string;
“date” sub attribute datatype date;
“name” sub attribute datatype string;

#roles and relationships

“screens” sub relationship
relates screenedAt
relates Screens;
“category” sub relationship
relates hasCategory;
“date” sub relationship
relates hasRuntime

I am getting the error “Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 50, Size: 43” Since I am new to Grakn, please explain me what could have caused this error and how to correct it.

thanks
pvs


#2

Hi pvs, welcome to the community!

A couple of things:

  1. On the screen relationship, you seem to get the name of the role player and relationship mixed up:
    “theater” sub entity has name plays screens plays hasRuntime
    “screens” sub relationship relates screenedAt relates Screens;

for example, this is how I would fix it:

theater sub entity has name plays screens ;
screening sub relationship relates screenedAt relates screens;
  1. You have both an attribute and a relationship named date:
“date” sub attribute datatype date;
“date” sub relationship relates hasRuntime

I’ve performed some cleaning to the schema you posted. There is no more “date” relationship - entities owns the “date” attribute directly:

define

movie sub entity has title has instance-id plays screenedAt has runtime;
showtime sub entity has runtime;
genre sub entity has category plays hasCategory;
theater sub entity has name plays screens has runtime;

instance-id sub attribute datatype string;
title sub attribute datatype string;
category sub attribute datatype string;
runtime sub attribute datatype date;
name sub attribute datatype string;

screening sub relationship relates screenedAt relates screens;
category-structure sub relationship relates hasCategory;

Let me know if this fixes your error.