cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Query not working

Hello Friends

I am new to Neo4j . I am trying to run simple Query but running into some issues which i am not able to figure out . Your help will be appreciated .
When I run following Query

Match(a:Procedure)-[n:PROFESSIONAL_RATE]->(b:RVU)Where NOT n.Modifer="All" RETURN *

why this query does not return any results . where as if I run below Query this will the result

Match(Procedure)-[n:PROFESSIONAL_RATE]->(RVU)Where NOT n.Modifer="All" RETURN *

But if I change return state like

Match(Procedure)-[n:PROFESSIONAL_RATE]->(RVU)Where NOT n.Modifer="All" RETURN Procedure.id

I see result is coming but all are null .

Any thoughts ?

11 REPLIES 11

the first statement of

Match(a:Procedure)-[n:PROFESSIONAL_RATE]->(b:RVU)Where NOT n.Modifer="All" RETURN 

says find me a node with a label of :Procedure which has a relationship named :PROFESSIONAL_RATE and this relationship is attached to another node which has a lable of :RVU

however the 2nd statement of

Match(Procedure)-[n:PROFESSIONAL_RATE]->(RVU)Where NOT n.Modifer="All" RETURN 

says find me ANY node, regardless of label which has a relationship named :PROFESSIONAL_RATE and this relationship is attached to ANY other node, regardless of label.

So the 1st statement is more restrictive.

Thanks Dan

Even though it is more restrictive ,shouldn't that work since I have Procedure Object in DB . Another Q

IF i use 2nd query why below statement would return null values . So statement is retuning no of correct rows but value is printing null ,

Match(Procedure)-[n:PROFESSIONAL_RATE]->(RVU)Where NOT n.Modifer="All" RETURN Procedure.id,Procedure.Short_Desc

what does

Match(Procedure)-[n:PROFESSIONAL_RATE]->(RVU)Where NOT n.Modifer="All" RETURN properties(Procedure) limit 3;

return. This should produce at most 3 rows of output and for each row report the property names for each node associated with Procedure

Dana

It return 3 rows but blank like this .

properties(Procedure)
{

}
{

}
{

}

But if I run below Query then I get following results

MATCH (n:Procedure) RETURN n LIMIT 25

"Update_Date": "2019-09-26",
"Type": "HCPCS",
"Full_Desc": "Assistive listening device, personal fm/dm transmitter assistive listening device",
"Short_Desc": "ALD PERS FM/DM TRANSMITTER ALD",
"id": "V5288",
"Long_Desc": "ASSIST LISTEN DEVC PERS FM/DM TRANSMITTER ALD",
"Created_Date": "2019-09-26"
}
{
"Update_Date": "2019-09-26",
"Type": "HCPCS",
"Short_Desc": "ALD PERS FM/DM ADPTR/BOOT CPLG RECV",
"Full_Desc": "Assistive listening device, personal fm/dm adapter/boot coupling device for receiver, any type",
"id": "V5289",
"Long_Desc": "ASSIST LIST DEVC PERS FM/DM ADPTR/BOOT CPLG RECV",
"Created_Date": "2019-09-26"
}

better yet run

Match(Procedure)-[n:PROFESSIONAL_RATE]->(RVU)Where NOT n.Modifer="All" RETURN properties(Procedure) return id(Procedure) limit 3

which will return 3 rows and return the internal Neo4j id for the 1st 3 nodes which have this relationship match. then using these 3 values if you then run

match (n) where id(n)= <one of the values of the 3 returned by the first query>

you can then use the Neo4j browser and see that this node does have a relationshi named PROFESSIONAL_RATE and this node has 0 properties.

But in general maybe we are chasing the wrong issue. As a matter of best practices and for best performance generally you should include a label in your match statement.
For example a match (Procedure)..... is going to perform a AllNodesScan which if you have 100 million nodes, we will thus traverse over these 100 million nodes. Whereas as a match (n:Procedure)..... where there are 100 million nodes but only 20k nodes with a label of :Procedure will perform a NodesByLabelScan and thus only interate over the 20k nodes, rather than the 100 million nodes

Hi Dana

I run the first Query and I got

properties(Procedure) id(Procedure)
{ } 33575
{ } 33577
{ } 33578

Then I run following query
match(n) where id(n)=33575 return n

and as you told I got a node with releationship but no properties . What is issue ? Does it mean I have duplicate nodes in DB where some has properties and some does not .

Yes
You have nodes, for example at internal id of 33575, 33577, and 33578 which have a relationship but the node has no properties.
How the nodes got there ??? ????

Dana
I am very new to neo4J less than a week old . I used import to load the data .

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///OPTUM_HCPCS_BASE_2019_10_update.tab" AS line
FIELDTERMINATOR '\t'
MERGE(line.HCPCS_CODE:Procedure{id:line.HCPCS_CODE})
ON CREATE SET
p.Short_Desc =line.SHORT_DESCRIPTION,
p.Long_Desc=line.LONG_DESCRIPTION,
p.Full_Desc = line.FULL_DESCRIPTION,
p.Type="HCPCS",
p.Update_Date = Date(),
p.Created_Date = Date()
ON MATCH SET
p.Short_Desc =line.SHORT_DESCRIPTION,
p.Long_Desc=line.LONG_DESCRIPTION,
p.Full_Desc = line.FULL_DESCRIPTION,
p.Update_Date = Date()

I am trying to drop the node but looks like there is relationship created which I don't think it should have with blank node . This is what I have used to create relationship and RVU

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///PPRRVU19_JUL.csv" AS line
MATCH(r:Procedure{id:line.HCPCS})
CREATE( p:RVU{
Work_RVU: toint(line.Work_RVU),
Non_FAC_PE_RVU:toint(line.Non_FAC_PE_RVU),
FAC_PE_RVU:toint(line.FAC_PE_RVU),
MP_RVU:toint(line.MP_RVU),
Non_Fac_Total:toint(line.Non_Fac_Total),
Fac_Total:toint(line.Fac_Total),
Status_Code : line.Status_Code,
Medicare_Ind : line.Medicare_Ind,
PCTC :line.PCTC,
Global_Days :line.Global_Days,
Multi_Proc:line.Multi_Proc,
Bilat_Proc:line.Bilat_Proc,
Asst_Surg:line.Asst_Surg,
Co_Surg:line.Co_Surg,
Team_Surg:line.Team_Surg,
Endo_Base:line.Endo_Base,
Cov_Factor:line.Cov_Factor,
Update_Date:Date(),
Created_Date:Date()
})
with p,line
MERGE(r)-[x:PROFESSIONAL_RATE{StartDate:Date(),Enddate:date("2999-12-31"),Modifer:coalesce(line.MOD,"All")}]->(p)

Once again thanks a lot to helping me out in this .

Regards
Pradeep

Dana

I think I figure out how it is creating a empty object . IT is because of

MERGE(r)-[x:PROFESSIONAL_RATE{StartDate:Date(),Enddate:date("2999-12-31"),Modifer:coalesce(line.MOD,"All")}]->(p)

Instead of (p) i should have used (r) ..

So what happened when you used (r) instead of (p)?

Inquiring minds want to know 😉

Duane Nickull