Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation / Elasticsearch query endpoint - query samples #7722

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
}
]
}
}
}
```