Query Caching

In this section, learn how to fasten, and setup Query Caching for your Neo4j data source. To check more about data source configuration, click here.

On this Page


Query Caching helps to fasten loading your Neo4j's data, by caching the results into Elasticsearch. This component is offered as a part of Platform Services. The basic functionality of this service is to retrieve data result from Neo4j, and then store the result for selected cache duration into Elasticsearch.

If you use Query Caching service, the data may not be real time. Usually the data is cached for the defined cache duration, hence if you want real time data, please use original Neo4j's connectivity URL.

Integration of Neo4j data source with Query Caching service


  • Go to Data source configuration in Grafana.
  • Under HTTP settings, enter the URL as - http://hostname:portno/PlatformService/externalApi/datasource/neo4jds (Note: Query Caching can be only configured by using the Platform Service URL). Select Access as proxy.

    In the URL, please input the Host & Port No., where PlatformService.war is hosted.

  • Select Basic Auth in HTTP Auth.
  • Enter Basic Auth Details (Note: Please input the admin credentials or create new user with admin access in this section).
  • Click Save & Test. It shall return a confirmation, "Data Source is working properly".

Configuring Neo4j - Query Caching in panels


  • Go to Dashboards, select a panel to configure.
  • Select the configured Neo4j query caching data source.
  • Input the cypher query in the query editor, select the option "Cache results".
  • Select the type of caching, and it's value.
  • Save the panel, and dashboard.

  • There are 2 types of caching, which you can select as per your convenience. 

    Types of Caching - 


    Fixed Time: In this type of caching, the results will cached for the selected hour duration and the Grafana's time selector would be disabled for the selected time duration in hours.

    Variance Time: In this type of caching, the results will be cached in percentage based on the duration selected in Grafana's time selector. Eg: If duration is set to Last 3 hours and the Variance Time is 5%, then results will be cached for 9 minutes (5% of 3 hours).

Customizing Elasticsearch - Query Cache Index (Applicable only for Insights version equal to or less than 8.2)


Query Caching Index Property in server-config.json

"queryCache":
{
     "esCacheIndex": "neo4j-cached-results-custom"
}

Important Note :  Just Make sure that, while configuring this in server-config.json esCacheIndex doesn't contain and subsection or slash(/), In 5.6.4 ES version data after slash(/) treated as type.

 In the above property the custom index is defined as neo4j-cached-results-custom. If you add your custom index, the URL where results will be stored is - http://hostname:9200/your-set-custom-index/querycacheresults/.

In the URL, please input the Host & Port No., where Elasticsearch is hosted and running.

If index is not created automatically then use following curl command to create index in ES

            curl -X PUT "localhost:9200/neo4j-cached-results-custom?pretty" -H 'Content-Type: application/json' -d'{  "settings" : { "index" : {  "number_of_shards" : 3,  "number_of_replicas" : 2 }                }}'

          If issue still persist just restart tomcat once and check 


Query Cache Using internal in-memory EhCache (Applicable only for Insights version equal to or greater than 8.3)


Important Note :  Just Make sure that, if you are using Insights Platform service version greater then and equal to 8.3 then no need to install ElasticSearch DB for this functionality , query caching archive through in memory EhCache mechanism instead of ElasticSearch DB 

©2021 Cognizant, all rights reserved. US Patent 10,410,152