Wazed Ali
Wazed Ali

Reputation: 33

CKAN "autocomplete.js" module is not working ( CKAN version 2.8)

I installed CKAN 2.8 version and I am trying to fetch keywords/terminologies from https://terminologies.gfbio.org/api/ using build in CKAN javascript module name "autocomplete.js".[https://github.com/ckan/ckan/blob/master/ckan/public/base/javascript/modules/autocomplete.js#L76]

But as I have supplied endpoint link to "data-module-source = https://terminologies.gfbio.org/api/terminologies/search?query=Acetobacter%20aceti" there is no response.... My frontend HTML code at CKAN >>

<input name="search" data-module="autocomplete" data-module- 
source="https://terminologies.gfbio.org/api/terminologies/search? 
query=Acetobacter%20aceti" />

but there is no API call generated from CKAN site to the remote endpoint i.e "https://terminologies.gfbio.org/api" with the following code.

<input name="search" data-module="autocomplete" data-module- 
source="https://terminologies.gfbio.org/api/terminologies/search? 
query=Acetobacter%20aceti" />

Upvotes: 0

Views: 247

Answers (1)

Andrew Watkins
Andrew Watkins

Reputation: 11

The autocomplete module is in ckan/javascript modules and is therefore designed to run on the client side. i.e the input form on the browser should be calling the API.

So you probably don't see a call from your ckan server to the API. But you may see it in the network output of the browser.

Second you need to generate an appropriate API call that takes an incomplete string and returns a match list.

for example the standard tag search calls (after typing java) http://ckan:5000/api/2/util/tag/autocomplete?incomplete=ora might return {"ResultSet": {"Result": [{id: "orange", text: "orange"}]

So you will need the remote API to return as similar array of strings that can be displayed.

There may be ways to override the plugin so as to parse and restructure the API result on the client side - If you find them let me know :). Otherwise you may need a server side microservice that takes a partial request, calls the gfbio api and reshapes the result.

Upvotes: 0

Related Questions