-
-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 4.2.x] Documentation / Elasticsearch query endpoint - query…
… samples (#7732) * Documentation / Elasticsearch query endpoint - query samples * Add step by step instructions for running eamples * Update docs/manual/docs/api/search.md Co-authored-by: François Prunayre <[email protected]> * Update docs/manual/docs/api/search.md Co-authored-by: François Prunayre <[email protected]> * Update docs/manual/docs/api/search.md Co-authored-by: François Prunayre <[email protected]> --------- Co-authored-by: Jose García <[email protected]> Co-authored-by: Jody Garnett <[email protected]> Co-authored-by: François Prunayre <[email protected]>
- Loading branch information
1 parent
9e4603f
commit f0472bd
Showing
2 changed files
with
157 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,162 @@ | ||
# Search Service | ||
|
||
## Elasticsearch | ||
|
||
GeoNetwork provides a full Elasticsearch end-point: ``/srv/api/search/records/_search`` | ||
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](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html) (Elasticsearch) | ||
- [Search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html) ( Elasticsearch Guide ) | ||
- [Multi search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) (Elasticsearch Guide) | ||
|
||
## Search API examples | ||
|
||
This section provides some query `POST` examples of `/srv/api/search/records/_search` end-point: | ||
|
||
1. To test examples navigate Swagger API documentation at `/srv/api/index.html` | ||
|
||
2. Locate the *search* heading, and the `/search/records/_search` `POST` end-point | ||
|
||
3. Use the *Try it out* button with: | ||
|
||
* **bucket**: `metadata` | ||
* **relatedType**: | ||
* **Request body**: Chosen from the examples below | ||
|
||
4. Press **Execute** to run the example. | ||
|
||
![](img/swagger-search-endpoint.png) | ||
|
||
### Text search query | ||
|
||
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: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: | ||
|
||
```json | ||
{ | ||
"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: | ||
|
||
```json | ||
{ | ||
"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: | ||
|
||
```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" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` |