Expand my Community achievements bar.

GraphQL Filter rules are not coming in the SQL query in the backend.

Avatar

Adobe Champion

 

I am trying to query a content fragment inside JCR , which matches a property value. Can someone guide if this query is correct?

 When I run this query in GraphQL tool, it gives node traversal and in the SQL query, I cannot see, it is picking the properties i gave. Node traversal may be due to lack of indexing the properties. But the query is not picking the filter rules I gave in my graphQL query.

 

JCR Query from logs: 

8.142.194 [1671637031153] POST /content/_cq_graphql/global/endpoint.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndex$FulltextPathCursor Index-Traversed 100000 nodes with filter Filter(query=SELECT asset.* FROM [dam:Asset] AS asset WHERE ISDESCENDANTNODE(asset, '/content/dam') AND asset.[jcr:content/contentFragment] = CAST('true' AS BOOLEAN) AND asset.[jcr:content/data/cq:model] = '/conf/test-inc/settings/dam/cfm/models/product-model' ORDER BY asset.[jcr:path], path=/content/dam//*, property=[jcr:content/contentFragment=[true], jcr:content/data/cq:model=[/conf/test-inc/settings/dam/cfm/models/product-model]])

 

 

GraphQL Query used:

query{
productModelList(filter:{
scancode:{
_expressions:[
{
value: "10164436768"
_operator: EQUALS
}
]
}
}){
items{
articleId
}
}}

 

Can someone advise what is wrong in this query?

3 Replies

Avatar

Employee Advisor

@P_V_Nair I ran similar query and then checked Query Performance, in my case it is picking oak:index/fragment which is not causing the above traversal error. See the screen shot below:

krati_garg_0-1671643621340.png

 

Can you please check the query performance on your system using explain query and determine which index is getting picked up.

 

Also, can you please confirm that you have installed the essential package with your graphql set up: - Graph QL OAK Index (cfm-graphql-index-def-1.0.0.zip)

https://kiransg.com/2021/12/04/aem-content-fragments-with-graphql-getting-started-with-graphql/

 

Avatar

Adobe Champion

@krati_garg  Thanks for looking int this. But my question was more around if the query was correct. Though I gave some parameters in the filter, that was never picked in the SQL query. Can you please share the query you ran as well?

Avatar

Adobe Champion

@krati_garg  I could see the query is working correctly in my local. But is failing in dev environment. Below is the graphQL query i used

 

query{

  testModelList(filter:{

  scancode:{

    _expressions:[

      {

      value: "10164436768"

        _operator: EQUALS

      }

    ]

  }

}){

  items{

   articleId

  }

}}

 

But the jcr query in the log was 

(query=SELECT asset.* FROM [dam:Asset] AS asset WHERE ISDESCENDANTNODE(asset, '/content/dam') AND asset.[jcr:content/contentFragment] = CAST('true' AS BOOLEAN) AND asset.[jcr:content/data/cq:model] = '/conf/aem-testinc/settings/dam/cfm/models/test-model' ORDER BY asset.[jcr:path], path=/content/dam//*, property=[jcr:content/contentFragment=[true], jcr:content/data/cq:model=[/conf/aem-testinc/settings/dam/cfm/models/test-model]])

 

I made sure i have indexed all properties, but still not giving any results and i don't see the filter expression in graphql query was considered in the jcr query