Hi Martyn,
Your (updated) code runs as expected for me.
Used this minimal schema:
DROP ALL
CREATE VERTEX Person (PRIMARY_ID id INT, name STRING, age INT)
CREATE GRAPH MyGraph (*)
Loaded this data set via Studio:
1,Thorin,195
2,Fili,82
3,Kili,77
4,Oín,167
5,Glóin,158
6,Balin,178
7,Dwalin,169
8,Ori,76
9,Dori,114
10,Nori,104
11,Bifur,127
12,Bofur,98
13,Bombur,107
14,Bilbo,50
15,Gandalf,5000
Installed your query (only changed the vertex name):
CREATE QUERY getAllPeopleByKeyword(STRING keyword) FOR GRAPH MyGraph {
STRING name = "";
STRING wildcard = "%";
name = wildcard + lower(keyword) + wildcard;
arrPeople = {Person.*}; # initialized with all vertices of type 'people'
arrPeopleFiltered =
SELECT v FROM arrPeople:v
WHERE lower(v.name) LIKE name;
PRINT arrPeopleFiltered;
}
And it runs as expected in GSQL:
GSQL > RUN QUERY getAllPeopleByKeyword(“LI”)
{
“error”: false,
“message”: “”,
“version”: {
"schema": 0,
"edition": "enterprise",
"api": "v2"
},
“results”: [{“arrPeopleFiltered”: [
{
"v_id": "2",
"attributes": {
"name": "Fili",
"age": 82
},
"v_type": "Person"
},
{
"v_id": "6",
"attributes": {
"name": "Balin",
"age": 178
},
"v_type": "Person"
},
{
"v_id": "3",
"attributes": {
"name": "Kili",
"age": 77
},
"v_type": "Person"
},
{
"v_id": "7",
"attributes": {
"name": "Dwalin",
"age": 169
},
"v_type": "Person"
}
]}]
}
GSQL > RUN QUERY getAllPeopleByKeyword(“li”)
{
“error”: false,
“message”: “”,
“version”: {
"schema": 0,
"edition": "enterprise",
"api": "v2"
},
“results”: [{“arrPeopleFiltered”: [
{
"v_id": "2",
"attributes": {
"name": "Fili",
"age": 82
},
"v_type": "Person"
},
{
"v_id": "6",
"attributes": {
"name": "Balin",
"age": 178
},
"v_type": "Person"
},
{
"v_id": "3",
"attributes": {
"name": "Kili",
"age": 77
},
"v_type": "Person"
},
{
"v_id": "7",
"attributes": {
"name": "Dwalin",
"age": 169
},
"v_type": "Person"
}
]}]
…and in Studio as well.
Best regards,
Szilard
On Friday, March 27, 2020 at 12:05:42 AM UTC, Martyn Bowis wrote:
Thanks I was trying to find lower and upper.
However, I have tried the following, and do not get a result, even when using the same case as that which I am searching for:
CREATE QUERY getAllPeopleByKeyword(STRING keyword) FOR GRAPH MyGraph {
STRING name = "";
STRING wildcard = "%";
name = wildcard + lower(keyword) + wildcard;
arrPeople = {people.*}; # initialized with all vertices of type 'people'
arrPeopleFiltered = SELECT v FROM arrPeople:v
WHERE lower(v.name) LIKE name;
PRINT arrPeopleFiltered;
}
The query does not show an error in GraphStudio, however, there is something incorrect. What might it be please?
Thanks