Hello
We have Flexible model which has Entity view and then a property named parent refers to Entity back as an edge. Now our user sends us an query to get all the entities say whose name is “SomeString”. And then we construct a query as below, but it errors out.
{
"with": {
"Entity": {
"nodes": {
"filter": {
"and": [
{
"matchAll": {}
},
{ "hasData": [
{
"type": "view",
"space": "slb-pdm-dm-governed",
"externalId": "Entity",
"version": "1_7"
}
]},
{"or": [
{
"and": [
{
"nested": {
"scope": [
"slb-pdm-dm-governed",
"Entity/1_7",
"parent"
],
"filter": {
"in": {
"property": [
"node",
"name"
],
"values": [
"SomeString"
]
}
}
}
}
]
}
]}
]
},
"chainTo": "destination",
"direction": "outwards"
}
},
"parent.Entity": {
"nodes": {
"from": "Entity",
"filter": {
"and": [
{
"hasData": [
{
"type": "view",
"space": "slb-pdm-dm-governed",
"externalId": "Entity",
"version": "1_7"
}
]
},
{
"in": {
"property": [
"node",
"externalId"
],
"values": [
"56debee29ada4609beff4c12bb9244a3"
]
}
}
]
},
"through": {
"source": {
"space": "slb-pdm-dm-governed",
"externalId": "Entity",
"version": "1_7",
"type": "view"
},
"identifier": "parent"
},
"chainTo": "destination",
"direction": "outwards"
}
}
},
"select": {
"Entity": {
"sources": [
{
"source": {
"space": "slb-pdm-dm-governed",
"externalId": "Entity",
"version": "1_7",
"type": "view"
},
"properties": [
"name",
"parent"
]
}
]
},
"parent.Entity": {
"sources": [
{
"source": {
"space": "slb-pdm-dm-governed",
"externalId": "Entity",
"version": "1_7",
"type": "view"
},
"properties": [
"name"
]
}
]
}
}
}
with an error- {
"error": {
"code": 400,
"message": "Invalid in filter with property reference [node, name]. Property reference must have the format [<space>, <externalId|externalId/version>, <property>] or [<node|edge>, <property>]. Valid base properties are [space, externalId, createdTime, lastUpdatedTime, type] for node, and [space, externalId, createdTime, lastUpdatedTime, startNode, endNode, type] for edge."
}
}
As we get the name from the user as input we really dont know about the external Id at that point in time. How do we go with this ?
Other way we can do is we dont pass edge filter in Views filter part rather we pass it in edges filter, but then we get all the nodes available and then we have to traverse through all the nodes to find out relevant node. Can you help here?
Regards,
Neeraj B
Solved
Unable to filter the edges in an efficient manner using model/instances/query endpoint
Best answer by Arild Eide
Thanks for reaching out!
Specifically, to the error message your are facing: When filtering by value of some property that you have defined on the view, the query also needs to refer to the view that has property in question. This is different from the base properties like space and externalId, like you are doing in the second filter.
So I think the filter should be something like:
"filter": {"in": {"property": ("slb-pdm-dm-governed", "Entity/1_7", "name"), "values": ["SomeString"]}},
Hope this helps.
Thanks
Arild Eide
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.