Search Service
GeoNetwork provides a access to Elasticsearch /srv/api/search/records/_search
and /srv/api/search/records/_msearch
end-points. These endpoints accept POST
requests, with request body containing an Elasticsearch JSON query.
Reference
- Search API ( Elasticsearch Guide )
- Multi search API (Elasticsearch Guide)
Search API examples
This section provides some query POST
examples of /srv/api/search/records/_search
end-point:
-
To test examples navigate Swagger API documentation at
/srv/api/index.html
-
Locate the search heading, and the
/search/records/_search
POST
end-point -
Use the Try it out button with:
- bucket:
metadata
- relatedType:
- Request body: Chosen from the examples below
- bucket:
-
Press Execute to run the example.
Text search query
Query with any field for metadata containing the string infrastructure
, using a query with Lucene syntax and excluding metadata templates:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "+anytext:infrastructure "
}
}
],
"filter": [
{
"term": {
"isTemplate": {
"value": "n"
}
}
}
]
}
}
}
Subset results
Query with any field for metadata containing the string infrastructure
, using a query with Lucene syntax and excluding metadata templates, returning a subset of the information:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "+anytext:infrastructure "
}
}
],
"filter": [
{
"term": {
"isTemplate": {
"value": "n"
}
}
}
]
}
},
"_source": {
"includes": [
"uuid",
"id",
"resourceType",
"resourceTitle*",
"resourceAbstract*"
]
}
}
Dataset query
Query datasets with title containing the string infrastructure
, using a query with Lucene syntax and excluding metadata templates:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "+anytext:infrastructure +resourceType:dataset"
}
}
],
"filter": [
{
"term": {
"isTemplate": {
"value": "n"
}
}
}
]
}
}
}
Revision date query
Query datasets with a revision date in June 2019 and excluding metadata templates: