Gosforth
(Gosforth)
February 18, 2021, 1:34pm
1
In Neo4j browser I run command to search for product:
CALL db.index.fulltext.queryNodes("ProductNameIndex", "product_name: some product") YIELD node, score
RETURN node.product_name, score
It works.
So I want to execute this command to http api (https://neo4j.com/docs/http-api/current/actions/query-format/ ). According the doc it should be:
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes("ProductNameIndex", $prod_desc_param) YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "Some product"}}}]}
It does not work: "Could not parse the incoming JSON"
Looks correct.
What I'm doing wrong?
Regards
using https://jsonformatter.curiousconcept.com/ and entering
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes("ProductNameIndex", $prod_desc_param) YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "Some product"}}}]}
will also report unable to parse the json
However there's no indication of Neo4j version but as tested using Neo4j version 4.2.1 and https://www.postman.com/ so as to submit the statement, if I modify to
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes(\"ProductNameIndex\", \" product name: $prod_desc_param.product_name \") YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "Some product"}}}]}
the the Neo4j Servers logs\query.log indicates the query was parsed thru the HTTP API as
2021-02-18 17:52:15.558+0000 INFO id:22 - 1844 ms: 72 B - server-session http 192.168.86.21 /db/neo4j/tx neo4j - - CALL db.index.fulltext.queryNodes("ProductNameIndex", " product name: $prod_desc_param.product_name ") YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12 - {prod_desc_param: {product_name: 'Some product'}} - runtime=pipelined - {}
Gosforth
(Gosforth)
February 18, 2021, 6:07pm
3
dana_canzano:
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes(\"ProductNameIndex\", \" product name: $prod_desc_param.product_name \") YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "Some product"}}}]}
Thank you.
Your code is not working for me
According the doc it should be:
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes(\"ProductNameIndex\", $prod_desc_param) YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "Some product"}}}]}
But same, no result
Your code is not working for me
???? how so? You get an error? You get unexpected results? it hangs?
According the doc
do you have a specific doc reference?
Gosforth
(Gosforth)
February 18, 2021, 6:11pm
5
dana_canzano:
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes(\"ProductNameIndex\", \" product name: $prod_desc_param.product_name \") YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "Some product"}}}]}
It says: "Could not parse the incoming JSON"
Gosforth
(Gosforth)
February 18, 2021, 6:14pm
6
I'm sending this to server:7474/db/neo4j/tx/commit
i did a copy-n-paste of your
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes(\"ProductNameIndex\", $prod_desc_param) YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "Some product"}}}]}
as is and ran it through JSON Formatter & Validator and it indicated all was well.
but when using Postman and sending your statement to localhost:7474/db/neo4j/txn I received error message
"errors": [
{
"code": "Neo.ClientError.Statement.SyntaxError",
"message": "Type mismatch for parameter 'prod_desc_param': expected String but was Map, Node or Relationship (line 1, column 55 (offset: 54))\n\"CALL db.index.fulltext.queryNodes(\"ProductNameIndex\", $prod_desc_param) YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12\"\n ^"
}
note this body is not the same as my initial post as to how to address.
But also how are you sending the request? via curl or some other rest client? ???
Gosforth
(Gosforth)
February 18, 2021, 6:52pm
9
Im using Pentaho PDI. It replays "Could not parse the incoming JSON" when I send this JSON:
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes(\"ProductNameIndex\", \" product_name: $prod_desc_param.product_name \") YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "Some product"}}}]}
But in Postman it returns emply array:
{
"results": [
{
"columns": [
"node.product_name",
"product_id",
"score"
],
"data": []
}
],
"errors": []
}
When I correct it to:
{"statements": [{"statement": "CALL db.index.fulltext.queryNodes(\"ProductNameIndex\", \"product_name: some product \") YIELD node, score RETURN node.product_name, node.product_id AS product_id, score LIMIT 12","parameters": {"prod_desc_param": {"product_name": "some product"}}}]}`
It works.
So API is not able to read array {"product_name": "some product"}
and if you dont submit with the "parameters" but rather simply hard code do you get expected results?
Gosforth
(Gosforth)
February 18, 2021, 7:24pm
11
Yes, it works. But it was working for me before. I started this subject because I expeced that 'paramters' will give me possibility to escape characters automatically (', , "...).
Now I have to convert search string with my own functions.