geonetwork / geonetwork-microservices

GNU General Public License v2.0
13 stars 18 forks source link

Searching / XML Searcher and XSLT Searcher #19

Closed fxprunayre closed 3 years ago

fxprunayre commented 3 years ago

The main search service is an Elasticsearch proxy taking care of user privileges.

This main searcher is always in charge of searches and can be decorated to accept custom search API and custom response format. For this, 3 types of searcher can be defined and the following examples are provided:

  1. Searcher returning index document as JSON (eg. main searcher)
  2. Searcher returning index document as simple XML (eg. RSS searcher)
  3. Searcher returning more elaborated response using XSLT on the complete metadata (eg. XsltSearchController)

Query as usually expressed using the Elasticsearch API but a searcher can customize this and take URL parameter and build the corresponding query (eg. RSS searcher).

The main searcher is the fastest option and does not require any database connection.

Test the search:


# RSS Search service 
curl 127.0.0.1:9902/portal/api/search/records/rss \
    -H "Accept: application/rss+xml"

# XSLT based search service 
# - Response in record format
curl 127.0.0.1:9902/portal/api/search/records/xslt \
    -H "Accept: application/gn-own" \
    -H "Content-type: application/json" \
    -X POST \
    -d '{"from": 0, "size": 1, "query": {"query_string": {"query": "+isTemplate:n"}}}'

# - Response in record DCAT format
curl 127.0.0.1:9902/portal/api/search/records/xslt \
    -H "Accept: application/gn-dcat" \
    -H "Content-type: application/json" \
    -X POST \
    -d '{"from": 0, "size": 1, "query": {"query_string": {"query": "+isTemplate:n"}}}'

# Elasticsearch service
curl 127.0.0.1:9902/portal/api/search/records/_search \
    -H "Accept: application/json" \
    -H "Content-type: application/json" \
    -X POST \
    -d '{"from": 0, "size": 10, "query": {"query_string": {"query": "+isTemplate:n"}}}' | jq -r '.hits.total.value'