diff --git a/aql/convertQuery2.go b/aql/convertQuery2.go
index 0304a03a9404a4d3cedd06f7cd300faa0053de3c..28388d557957e8d6d486258214f574d137a17930 100644
--- a/aql/convertQuery2.go
+++ b/aql/convertQuery2.go
@@ -65,47 +65,92 @@ func createQuery(JSONQuery *entity.IncomingQueryJSON) *string {
 			switch element.typename {
 			case "entity":
 				entity := JSONQuery.Entities[element.pointer]
-				query += entityToQuery(entity)
+				query += entityToQuery(entity, JSONQuery)
 			case "relation":
 				relation := JSONQuery.Relations[element.pointer]
-				query += relationToQuery(relation)
+				query += relationToQuery(relation, JSONQuery)
 			case "function":
 				function := JSONQuery.GroupBys[element.pointer]
-				query += functionToQuery(function)
+				query += functionToQuery(function, JSONQuery)
 			case "filter":
 				filter := JSONQuery.Filters[element.pointer]
-				query += filterToQuery(filter)
+				query += filterToQuery(filter, JSONQuery)
 			}
 		}
 	}
+	return &query
 }
 
-func entityToQuery(element entity.QueryEntityStruct) string {
+func entityToQuery(element entity.QueryEntityStruct, JSONQuery *entity.IncomingQueryJSON) string {
 	thisname := fmt.Sprintf("e%v", element.ID)
 	ret := createLetFor(thisname, element.Name)
-	ret += "RETURN x\n)"
+	ret += "\tRETURN x\n)"
 	return ret
 }
 
-func relationToQuery(element entity.QueryRelationStruct) string {
-	thisname := fmt.Sprintf("e%v", element.ID)
+func relationToQuery(element entity.QueryRelationStruct, JSONQuery *entity.IncomingQueryJSON) string {
+	thisname := fmt.Sprintf("r%v", element.ID)
 	ret := createLetFor(thisname, element.Name)
+	ret += fmt.Sprintf("\tFOR y in %v%v\n")
 	return ret
 }
 
-func functionToQuery(element entity.QueryGroupByStruct) string {
-	thisname := fmt.Sprintf("e%v", element.ID)
+func functionToQuery(element entity.QueryGroupByStruct, JSONQuery *entity.IncomingQueryJSON) string {
+	thisname := fmt.Sprintf("g%v", element.ID)
 	element
 	ret := createLetFor(thisname)
 	return ret
 }
 
-func filterToQuery(element entity.QueryFilterStruct) string {
-	thisname := fmt.Sprintf("e%v", element.ID)
-	ret := createLetFor(thisname, fmt.Sprintf("e%v", element.FilteredID))
+func filterToQuery(element entity.QueryFilterStruct, JSONQuery *entity.IncomingQueryJSON) string {
+	thisname := fmt.Sprintf("f%v", element.ID)
+	ret := createLetFor(thisname, fmt.Sprintf("%v%v", typeToPrefix(element.FromType), element.FromID))
+	ret += fmt.Sprintf("\tFILTER x.%v %v %v\n", element.Attribute, wordsToLogicalSign((element.MatchType)), element.Value)
+	ret += "\tRETURN x\n)"
 	return ret
 }
 
 func createLetFor(variableName string, enumerableName string) string {
 	return "LET " + variableName + " = (\n\tFOR x IN " + enumerableName + "\n"
 }
+
+func typeToPrefix(pillType string) string {
+	switch pillType {
+	case "entity":
+		return "e"
+	case "relation":
+		return "r"
+	case "function":
+		return "g"
+	case "filter":
+		return "f"
+	default:
+		return ""
+	}
+}
+
+func tryGetFilter(toType string, toID int, JSONQuery *entity.IncomingQueryJSON) *entity.QueryFilterStruct {
+	for i := range JSONQuery.Filters {
+		filter := JSONQuery.Filters[i]
+		if filter.ToType == toType && filter.ToID == toID {
+			return &filter
+		}
+	}
+	return nil
+}
+
+func wordsToLogicalSign(word string) string {
+	if word == "LT" {
+		return "<"
+	} else if word == "LTE" {
+		return "<="
+	} else if word == "EQ" {
+		return "=="
+	} else if word == "GTE" {
+		return ">="
+	} else if word == "NEQ" {
+		return "!="
+	} else {
+		return ">"
+	}
+}
diff --git a/entity/queryStruct.go b/entity/queryStruct.go
index ed0fe657ff6db45d4c684a746c45add39dde1b8b..f8ae93c76d72ecfc19f2eefe6536afc3720a67f6 100644
--- a/entity/queryStruct.go
+++ b/entity/queryStruct.go
@@ -51,15 +51,17 @@ type QueryGroupByStruct struct {
 }
 
 type QueryFilterStruct struct {
-	ID           int
-	FilteredType string
-	FilteredID   int
-	Attribute    string
-	DataType     string
-	MatchType    string
-	Value        string
-	InType       string
-	InID         int
+	ID        int
+	FromType  string
+	FromID    int
+	ToType    string
+	ToID      int
+	Attribute string
+	DataType  string
+	MatchType string
+	Value     string
+	InType    string
+	InID      int
 }
 
 // QueryModifierStruct encapsulates a single modifier with its corresponding constraints