logo
down
shadow

How to log query statement to Neo4j server, is it possible?


How to log query statement to Neo4j server, is it possible?

By : user2950179
Date : November 17 2020, 11:52 AM
this one helps. The following is about http logging which also includes queries + params + results. It is not intended for production settings just debugging and testing.
This should work from 2.1.6, see: https://github.com/neo4j/neo4j/pull/3399
code :
 org.neo4j.server.http.unsafe.content_log.enabled=true
 org.neo4j.server.http.log.enabled=true
 <pattern>%fullRequest\n\n%fullResponse</pattern>
<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>data/log/http.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>data/log/http.%d{yyyy-MM-dd_HH}.log</fileNamePattern>
      <maxHistory>30</maxHistory>
    </rollingPolicy>

    <encoder>
      <!-- Note the deliberate misspelling of "referer" in accordance with RFC1616 -->
      <pattern>%h %l %user [%t{dd/MMM/yyyy:HH:mm:ss Z}] "%r" %s %b "%i{Referer}" "%i{User-Agent}" \nRequest:\n%fullRequest\nResponse:\n%fullResponse</pattern>
    </encoder>
  </appender>

  <appender-ref ref="FILE"/>
</configuration>
127.0.0.1 - - [04/Jan/2015:11:23:50 +0100] "POST /db/data/transaction/commit HTTP/1.1" 200 372 "http://localhost:7474/browser/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36" 
Request:
POST /db/data/transaction/commit HTTP/1.1
Origin: http://localhost:7474
X-stream: true
Cookie: SQLiteManager_currentLangue=4; __jrDevToolbarSessionId=0x1.b6e143f2c334p-3; JSESSIONID=1AFCE7DCF2D5D7134E933871EBF88252; OSESSIONID=OS1412075842834-2614241454738785158; connect.sid=s%3AkRY6%2B4RyW%2FC2ZUMjfIVqtRRo.shdI5G0zTKSq%2BzKevgXzLEdHnwjUDYP1JFlOhupRf2I; _ga=GA1.1.149316633.1397859613; _mkto_trk=id:773-GON-065&token:_mch-localhost-1384123755719-53900; undefined=0; __atuvc=0%7C47%2C0%7C48%2C1%7C49%2C5%7C50%2C13%7C51
Accept: application/json, text/plain, */*
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Referer: http://localhost:7474/browser/
Host: localhost:7474
DNT: 1
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,de-DE;q=0.6,de;q=0.4
Content-Length: 115
Content-Type: application/json;charset=UTF-8

{"statements":[{"statement":"match (n) return count(*)","resultDataContents":["row","graph"],"includeStats":true}]}
Response:
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json

{"results":[{"columns":["count(*)"],"data":[{"row":[0],"graph":{"nodes":[],"relationships":[]}}],"stats":{"contains_updates":false,"nodes_created":0,"nodes_deleted":0,"properties_set":0,"relationships_created":0,"relationship_deleted":0,"labels_added":0,"labels_removed":0,"indexes_added":0,"indexes_removed":0,"constraints_added":0,"constraints_removed":0}}],"errors":[]}


Share : facebook icon twitter icon
Compatibility neo4j-spatial with spring-data-neo4j-rest and neo4j CE 2.2.1 server mode?

Compatibility neo4j-spatial with spring-data-neo4j-rest and neo4j CE 2.2.1 server mode?


By : shexbeer
Date : March 29 2020, 07:55 AM
it fixes the issue Not yet, sorry, one of the many todos on my list :(.
But for the REST-Server it shouldn't matter. You would deploy the spatial plugin to Neo4j-Server and then it should use the indexes via the REST API.
Neo4J Multiple Match Statement in Single Query

Neo4J Multiple Match Statement in Single Query


By : naras1
Date : March 29 2020, 07:55 AM
With these it helps I want to get Total Count of VoteUp and VoteDown on Pixel in Single Query but it return TRUE RESULT when it have Greater then Zero Value that means VoteUp and VoteDown Greater then Zero. , I got Solution of My Question from Following Query:
code :
MATCH (n:pixel)WHERE ID(n)=7445 
RETURN  
size((n)-[:vote_up]-(:users)) as VoteUp,
size((n)-[:vote_down]-(:users)) as VoteDown
Neo4j / Cypher - Conditional set/create/etc statement based on count (or any previous query statement)

Neo4j / Cypher - Conditional set/create/etc statement based on count (or any previous query statement)


By : LeonAHe
Date : March 29 2020, 07:55 AM
Hope that helps How do you conditionally do a SET (or anything else) based on the result of a previous line? So for example the query below (which doesn't work atm), where I'm trying to update something based on if the count is 1 (and not do it otherwise). Query doesn't like statements after THEN so that's where the error is occurring. I've tried also using WHERE clauses but no luck as of yet. , This should work:
code :
MATCH (n:Thing { name: 'asdf' })
OPTIONAL MATCH (c)<-[:HAS_CHILD]-(p:Thing)-[:HAS_CHILD]->(n)
WITH p, n,
  CASE WHEN COUNT(c) = 1 then [1] else [] end as countOne
FOREACH (x in countOne | SET p.btogstate = 'closed')
DETACH DELETE n;
Neo4J query using calculations within RETURN statement

Neo4J query using calculations within RETURN statement


By : AurelienR
Date : March 29 2020, 07:55 AM
This might help you I have a simple model: , You can use WITH for intermediate calculations:
code :
//FIND ALL HEADS AND NUMBER OF SCHOOLS THEY WENT TO
MATCH (t:Teacher)
WHERE (t)-[:HAD]->(:Contract {leadership: 'Head'})
MATCH (t)-[:HAD]->(:Contract)-[:WITH]->(s:School)
WITH t,count(distinct(s)) as no_of_schools
RETURN toFloat(no_of_schools) / count(distinct(t))*100 AS ratio
ORDER BY ratio DESC
MATCH (t:Teacher)
WITH count(t) as tCount // don't need distinct here, but wouldn't hurt
MATCH (t:Teacher)
WHERE (t)-[:HAD]->(:Contract {leadership: 'Head'})
MATCH (t)-[:HAD]->(:Contract)-[:WITH]->(s:School)
WITH t,tCount,count(distinct(s)) as no_of_schools
RETURN toFloat(no_of_schools) / tCount*100 AS ratio
ORDER BY ratio DESC
Neo4j: Expected exactly one statement per query but got: 3

Neo4j: Expected exactly one statement per query but got: 3


By : Rodério Kunz
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Neo4j Browser can run only one query at time. You are trying to run 3:
Query 1:
code :
match (d {Name:'D'})-[:TO]-(b)
with collect(distinct b.Name) as neighbors
match (n)-[r:TO]->(m)
where
not (n.Name in (neighbors+'D'))
and
not (m.Name in (neighbors+'D'))
return n, r, m;
match (d {Name:'D'})-[:TO]-(b)-[:TO]->(leaf)
where not((leaf)-->())
return (leaf);
match (d {Name:'D'})-[:TO]-(b)<-[:TO]-(root)
where not((root)<--())

return (root)
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org