Md Tajul Islam
Md Tajul Islam

Reputation: 3

CKAN 2.9 datastore_search API

I am using CKAN 2.9 with python 3.8. I have my own ckan extension and now I want to change the search conditions from the datastore_search API. As an example if i search for "apple" my search result will also contain the query result of "banana" (condition: both are fruits). Now I have a few confusions after passing so many times with ckan:

  1. In which folder of ckan I will get /api/3/action/datastore_search result logics(i have gone through ckan/logic/action but I can't see anything with datastore_search)

  2. How can I extend and edit this file (datastore_search or datastore. I tried with example_idatastorebackend but it's not working)

  3. Is it possible to call ckan datastore_search API within my ckan extension plugin file?

Upvotes: 0

Views: 333

Answers (1)

P DeKraker
P DeKraker

Reputation: 50

The datastore is a separate extension its code is all stored in ckan/ckanext/datastore with the api functionality stored in ckan/ckanext/datastore/logic/action.py

It is possible to write an extension that overrides the default datastore_search action. You just need to implement your action as you would any other custom action (IActions interface). You do however need to ensure your extension is loaded after the datastore otherwise the default functionality will supersede your method.

It isn't a current example, but you can check out ckanext-dataproxy for an example of an extension that does something similar to what you are suggesting.

Upvotes: 0

Related Questions