Skip to content

Commit

Permalink
Documentation / Elasticsearch query endpoint - query samples
Browse files Browse the repository at this point in the history
  • Loading branch information
josegar74 committed Feb 8, 2024
1 parent 0a68eae commit 29222a4
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 138 additions & 1 deletion docs/manual/docs/api/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,145 @@

## Elasticsearch

GeoNetwork provides a full Elasticsearch end-point: ``/srv/api/search/records/_search``
GeoNetwork provides a full Elasticsearch end-point: `/srv/api/search/records/_search` that requires http `POST`,
accepting a payload with an Elasticsearch query.

Reference

- [Search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html) (Elasticsearch)

### Query examples

This section provides some query examples. To test them a `POST` request should be sent to the search end-point `/srv/api/search/records/_search` :

![](img/swagger-search-endpoint.png)


- Query with any field for metadata containing the string `infrastructure`, using a query with Lucene syntax and excluding metadata templates:

```json
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "+anytext: infraestructure "
}
}
],
"filter": [
{
"term": {
"isTemplate": {
"value": "n"
}
}
}
]
}
}
}
```

- 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:

```json
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "+anytext: infraestructure "
}
}
],
"filter": [
{
"term": {
"isTemplate": {
"value": "n"
}
}
}
]
}
},
"_source": {
"includes": [
"uuid",
"id",
"resourceType",
"resourceTitle*",
"resourceAbstract*"
]
}
}
```


- Query datasets with title containing the string `infrastructure`, using a query with Lucene syntax and excluding metadata templates:

```json
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "+anytext: infraestructure +resourceType:dataset"
}
}
],
"filter": [
{
"term": {
"isTemplate": {
"value": "n"
}
}
}
]
}
}
}
```

- Query datasets with a revision date in June 2019 and excluding metadata templates:

```json
{
"query": {
"bool": {
"must": [
{
"term": {
"resourceType": {
"value": "dataset"
}
}
},
{
"range": {
"resourceTemporalDateRange": {
"gte": "2019-06-01",
"lte": "2019-06-30",
"relation": "intersects"
}
}
}
],
"filter": [
{
"term": {
"isTemplate": {
"value": "n"
}
}
}
]
}
}
}
```

0 comments on commit 29222a4

Please sign in to comment.