Skip to content

Commit

Permalink
API / Example how to use search API from Google sheets. (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre authored Aug 19, 2022
1 parent 0460e27 commit 303f214
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Binary file added source/api/img/googlesheets-fn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/api/img/googlesheets-script.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions source/api/the-geonetwork-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ This is an example to trigger an XSL process on a set of records. It illustrates
Using the search API in Google sheet
====================================

In Extensions > App script create a new function. Here we create a function which run a search and return a list of
matching UUIDs:

.. figure:: img/googlesheets-script.png

.. code-block:: js
function getUuidForSearch(query) {
var options = {
'method' : 'post',
'contentType': 'application/json',
'payload' : "{\"query\":{\"query_string\":{\"query\":\"" + query + "\"}}}"
};
var response = UrlFetchApp.fetch('http://localhost:8080/catalogue/srv/api/search/records/_search', options);
var hits = JSON.parse(response).hits;
Logger.log(hits.hits);
return hits.hits.length > 0 ? hits.hits.map(function(v) {return v._id}).join('###') : null;
}
Then use the function in formula. Here we search for records matching particular keywords:

.. figure:: img/googlesheets-fn.png




Building client for the API using codegen
=========================================
Expand Down

0 comments on commit 303f214

Please sign in to comment.