Neo4j http API NullPointerException - neo4j

I am using the HTTP API to query the Neo4j server. The exact same queries with slightly different values do not work consistently. Infact the entire system breaks because of the NullPointer exception that is being thrown. Cannot figure out the root of this problem
{
"query":"START n=node( { current_user_node } ), n1 = node( { contact_node } ) CREATE UNIQUE n-[:has_contact {device: {device_id}, name: {name} }]->(n1)",
"params":{"current_user_node":2,"contact_node":5941,"device_id":"F1485935-48F8-4624-AF5D-67529AE91227","name":"Samir Coll "}
}
The above query returns
{
"exception": "NullPointerException",
"fullname": "java.lang.NullPointerException",
"stacktrace": []
}
I tried the above query in the neo4j-shell from the command line and the query returned a null.
While
{
"query":"START n=node( { current_user_node } ), n1 = node( { contact_node } ) CREATE UNIQUE n-[:has_contact {device: {device_id}, name: {name} }]->(n1)",
"params":{"current_user_node":1,"contact_node":5658,"device_id":"FA2C589A-6AB5-4D78-ADED-7146CA71D0FC","name":"Jayesh New"}
}
The above returns
{ "columns": [], "data": [] }
The data is empty as the relationship already exists.
I am running neo4j 2.0.0 stable. All the nodes mentioned in the above queries are valid. I am very unsure as to how to proceed with this. Would appreciate it if someone can help with the problem.

Related

Prometheus metric retruns no data

i have installed the prometheus-es-exporter for querying the elasticsearch and also i have written some queries.E.g one of the query looks like:
[query_database_connection_exception]
QueryIntervalSecs = 300
QueryIndices = logs.*
QueryJson = {
"size": 0,
"query": {
"query_string": {
"query": "message: \"com.microsoft.sqlserver.jdbc.SQLServerException: \" AND #timestamp:(>=now-1h AND <now)"
}
},
"aggs": {
"application": {
"terms": {
"field": "kubernetes.labels.app.keyword"
}
}
}
}
ES-Exporter exposes after the configuration the metric database_connection_exception_application_doc_count but i face the issue that sometimes i get in prometheus the error message:
This happens not only for this query but for other queries as well.My understanding and expectation is that if my query does not find the string com.microsoft.sqlserver.jdbc.SQLServerException for the last 1h it must return the value=0 in prometheus but for some reason it returns no data.How should i understand this?
ES-Exporter is running smoothly,health check of ES-Exporter and Elastic shows no error,all elastic nodes are at state green.

How can I run a Graphql query in a Rails console?

I have a Graphql query working in Graphiql:
query MyConfigurationType {
myConfiguration {
number
expirationDate
}
}
Returns
{
"data": {
"myConfiguration": {
"number": 1,
"expirationDate": "2022/10/04"
}
}
}
But I need to actually use that result in my app therefore I want to be able to run it in my rails console. There doesn't seem to be much info about this.
How would one go about executing a Graphql query in the Rails console?
After looking at some documentation the best I could manage to do was, in the Rails console do:
query_string = "query MyConfigurationType {
myConfiguration {
number
expirationDate
}
}"
and the run
result = MySchema.execute(query_string)
Which has a result of
=> #<GraphQL::Query::Result #query=... #to_h={"data"=>{"myConfiguration"=>{"number"=>1, "expirationDate"=>"2022/10/04"}}}>
Therefore one can now do
[1] pry(main)> result['data']
=> {"myConfiguration"=>{"number"=1, "expirationDate"=>"2022/10/04"}}

elasticsearch filter aggregation - multiple filters

Using ElasticSearch aggregation to aggregate data on my documents.
so the aggregation request looks something like this
{
"query":{
"bool":{
"filter":[
{
"terms":{
"status":[
"active",
"deleted"
]
}
},
{
"terms":{
"address_ids":[
4078,
4080
]
}
}
]
}
},
"aggregations":{
"neighbourhoods":{
"terms":{
"field":"neighbourhoods",
"size":100
}
},
"budgets_stats":{
"filter":{
"range":{
"budget":{
"lt":100000
}
}
},
"aggregations":{
"budget":{
"stats":{
"field":"budget"
}
}
}
}
}
}
i want to filter out documents that match ** budget lower than 100000 ** and add more filters to that specific aggregation.
I cant add it to the query clause, because i have other aggregation in which i dont want these budget filters to apply.
I cant use the filters aggregation either because it creates a different bucket for each filter - instead of 1 bucket with all filters applied to it.
How can create a filter aggregation with more than 1 filter? lets say the other condition should be
"budgets_stats":{
"filter":
{
"range":{
"vip_budget":{
"gt":500
}
}
}
}
i have tried using Array but its not working.
filter: [{:range=>{:budget=>{:lt=>100000}}}, {:range=>{:vip_budget=>{:gt=>500}}}]
getting this error (using rails gems)
Elasticsearch::Transport::Transport::Errors::BadRequest Exception: [400] {"error":{"root_cause":[{"type":"parsing_exception","reason":"Expected [START_OBJECT] under [filter], but got a [START_ARRAY] in [budgets_stats]","line":1,"col":233}],"type":"parsing_exception","reason":"Expected [START_OBJECT] under [filter], but got a [START_ARRAY] in [budgets_stats]","line":1,"col":233},"status":400}
Is this even possible? couldn't find a reference in the documentation of elastic / rails gems for elastic
Will appreciate any help,
Thanks

Gatling - Retrieve part of json and check equality

I'm using Gatling tool to load test my service.
I have following response from my server(just an example):
{
"result: {
"288249": {
"allowEdit": 1,
"cells": [
{
"rollupId": "288249",
"description": "Gatling description: 93"
},
{
"rollupId": "288249",
"description": "Gatling description: 83"
}
]
}
}
}
What I need is loop thought all $.result.288249.cells[*].description fields and verify that there's a value, which is equal to what I have in one of my session objects.
It should look similar to following pseudo code:
.check(
jsonPath("$.result.*.cells[*].description").contains("${mySessionValue})
)
Is there are method, which I can use in similar way ?
Thanks in advance!
I think, I've found the solution
.check(
jsonPath("$.result.*.cells[?(#.description == '${mySessionValue}')]")
.find
.exists
)
This should do the work.
You can loop thru as follows
$.each($.result, function(index,obj){
$.each(obj['cells'], function(innerInd, innerObj){
if( ${mySessionValue} == innerObj['description'] )
{
console.log('Found')
return
}
})
})

Client-side mutation with RANGE_ADD type doesn't include edge inside request payload

I'm trying to create new object using client-side mutation described below:
import Relay from 'react-relay'
export default class CreateThemeMutation extends Relay.Mutation {
static fragments = {
admin: () => Relay.QL`fragment on Admin { id }`,
};
getMutation() {
return Relay.QL`mutation { createTheme }`
}
getFatQuery() {
return Relay.QL`
fragment on CreateThemePayload {
admin { themes }
themeEdge
}
`
}
getVariables() {
return {
name: this.props.name,
}
}
getConfigs() {
return [{
type: 'RANGE_ADD',
parentName: 'admin',
parentID: this.props.admin.id,
connectionName: 'themes',
edgeName: 'themeEdge',
rangeBehaviors: {
'': 'append',
},
}]
}
}
Root query field admin is quite similar to viewer so this shouldn't be a problem. The problem is I haven't found themeEdge (which I believe should present) within the request payload (admin { themes } is there though):
query: "mutation CreateThemeMutation($input_0:CreateThemeInput!){createTheme(input:$input_0){clientMutationId,...F3}} fragment F0 on Admin{id} fragment F1 on Admin{id,...F0} fragment F2 on Admin{_themes2gcwoM:themes(first:20,query:""){count,pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},edges{node{id,name,createdAt},cursor}},id,...F1} fragment F3 on CreateThemePayload{admin{id,...F0,id,...F2}}"
variables: {input_0: {name: "test", clientMutationId: "0"}}
As a result outputFields.themeEdge.resolve inside the server-side mutation never get called and I see this message:
Warning: writeRelayUpdatePayload(): Expected response payload to include the newly created edge `themeEdge` and its `node` field. Did you forget to update the `RANGE_ADD` mutation config?
I've seen similar issue on github. However REQUIRED_CHILDREN isn't my case because the application has requested themes connection already. Am I missing something obvious? Should I paste more info? Thanks.
react-relay version: 0.6.1
I ran into the same issue and eventually solved it by making sure that my equivalent of themeEdge actually existed as an edge in my schema. If you grep your schema for themeEdge, does an object exist?
For reference, here's my edge definition tailored for you:
{
"name":"themeEdge",
"description":null,
"args":[],
"type":{
"kind":"NON_NULL",
"name":null,
"ofType":{
"kind":"OBJECT",
"name":"ThemeEdge",
"ofType":null
}
},
"isDeprecated":false,
"deprecationReason":null
}
and
{
"kind":"OBJECT",
"name":"ThemeEdge",
"description":"An edge in a connection.",
"fields":[{
"name":"node",
"description":"The item at the end of the edge.",
"args":[],
"type":{
"kind":"NON_NULL",
"name":null,
"ofType":{
"kind":"OBJECT",
"name":"Theme",
"ofType":null
}
},
"isDeprecated":false,
"deprecationReason":null
}
Also note that your rangeBehaviors must exactly match the query you use to retrieve your parent object. You can specify multiple queries as follows, which also shows the syntax for when your query contains multiple variables:
{
type: 'RANGE_ADD',
parentName: 'admin',
parentID: this.props.admin.id,
connectionName: 'themes',
edgeName: 'themeEdge',
rangeBehaviors: {
'': 'append',
'first(1).id($adminId)': 'append',
},
}

Resources