Skip to content

Commit 761a35b

Browse files
committed
demo: replace Elasticsearch with OpenSearch
1 parent 251d324 commit 761a35b

33 files changed

+3002
-28275
lines changed

.github/workflows/js-tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ on:
1919

2020
jobs:
2121
Tests:
22-
runs-on: ubuntu-20.04
22+
runs-on: ubuntu-latest
2323

2424
strategy:
2525
matrix:
26-
node-version: [18.x, 16.x]
26+
node-version: [22.x, 18.x, 16.x]
2727

2828
steps:
2929
- name: Checkout
30-
uses: actions/checkout@v3
30+
uses: actions/checkout@v4
3131

3232
- name: Use Node.js ${{ matrix.node-version }}
33-
uses: actions/setup-node@v3
33+
uses: actions/setup-node@v4
3434
with:
3535
node-version: ${{ matrix.node-version }}
3636

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,33 @@ Main features:
2727

2828
You can find a collection of examples in the `src/demos` folder:
2929

30-
- Elasticsearch, an example on how to query Elasticsearch (see below)
30+
- OpenSearch, an example on how to query OpenSearch (see below)
3131
- Zenodo.org, an example on how to query an Invenio 3 instance
3232
- CERN Videos, another Invenio 3 example
3333

3434
Install dependencies and run the React app to try them out (see steps below).
3535

36-
### Elasticsearch
36+
### OpenSearch
3737

38-
To run the Elasticsearch backend for the demo, you can use Docker. A `docker-compose` file with `ES 7` and `nginx` as reverse proxy is available and ready to use.
38+
To run the OpenSearch backend for the demo, you can use Docker. A `docker-compose` file with `ES 7` and `nginx` as reverse proxy is available and ready to use.
3939
Run the services:
4040

4141
```bash
42-
cd src/demos/elasticsearch/docker
42+
cd src/demos/opensearch/docker
4343
docker-compose up
4444
```
4545

4646
Then, init the demo data:
4747

4848
```bash
49-
curl -XPUT 'http://localhost:9200/random?pretty' -H 'Content-Type: application/json' -d @es7-mappings.json
50-
curl -XPOST 'http://localhost:9200/random/_bulk' -H 'Content-Type: application/json' --data-binary @es-random-data.json
49+
curl -XPUT 'http://localhost:9200/random?pretty' -H 'Content-Type: application/json' -d @os2-mappings.json
50+
curl -XPOST 'http://localhost:9200/random/_bulk' -H 'Content-Type: application/json' --data-binary @os-random-data.json
5151
curl -XGET 'http://localhost:9200/random/_count?pretty'
5252
```
5353

5454
Demo data have been randomly generated using <https://next.json-generator.com>.
5555

56-
> In case you want to clear your elastic search from data you can use `curl -X DELETE 'http://localhost:9200/_all'`
56+
> Delete data in the cluster: `curl -X DELETE 'http://localhost:9200/_all'`
5757
5858
## Developer guide
5959

docs/docs/connect_your_rest_apis.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: connect-your-rest-apis
33
title: Connect Your REST APIs
44
---
55

6-
React-SearchKit comes out of the box with a working adapter for [Elasticsearch 7](https://www.elastic.co/) and [Invenio](https://inveniosoftware.org) REST APIs. However, the library has been designed to allow the creation of custom adapters to plug in any REST API service.
6+
React-SearchKit comes out of the box with a working adapter for [OpenSearch 2](https://opensearch.org/) and [Invenio](https://inveniosoftware.org) REST APIs. However, the library has been designed to allow the creation of custom adapters to plug in any REST API service.
77

88
There are 2 ways of connecting your REST APIs:
99

@@ -12,12 +12,12 @@ There are 2 ways of connecting your REST APIs:
1212

1313
## Use one of the available
1414

15-
The `Elasticsearch` adapter can be configured by passing an object. The configuration will be injected directly in the [axios](https://github.com/axios/axios) instance used under the hood to perform network requests.
15+
The `OpenSearch` adapter can be configured by passing an object. The configuration will be injected directly in the [axios](https://github.com/axios/axios) instance used under the hood to perform network requests.
1616

1717
```jsx
18-
const searchApi = new ESSearchApi({
18+
const searchApi = new OSSearchApi({
1919
axios: {
20-
url: 'https://my.es.backend.org/search/',
20+
url: 'https://my.os.backend.org/search/',
2121
timeout: 5000,
2222
}
2323
});
@@ -100,12 +100,12 @@ Custom serializers can then be injected in the configuration of the adapter:
100100
const MyRequestSerializer = new MyRequestSerializer();
101101
const MyResponseSerializer = new MyResponseSerializer();
102102

103-
const searchApi = new ESSearchAPI({
103+
const searchApi = new OSSearchAPI({
104104
axios: {
105-
url: 'https://my.es.backend.org/search/',
105+
url: 'https://my.os.backend.org/search/',
106106
timeout: 5000,
107107
},
108-
es: {
108+
os: {
109109
requestSerializer: MyRequestSerializer,
110110
responseSerializer: MyResponseSerializer,
111111
},

docs/docs/filters_aggregations.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Filters allow to refine search results with exact match on specific fields. For
99

1010
In React-SearchKit, the query state contains a field called `filters` which contains the list of filters selected by the user.
1111

12-
[Filters](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html#filter-context) and [Aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html) are fundamental concepts of Elasticsearch.
12+
[Filters](https://opensearch.org/docs/latest/query-dsl/query-filter-context/) and [Aggregations](https://opensearch.org/docs/latest/aggregations/) are fundamental concepts of OpenSearch.
1313
However, they can be applied to any backend or REST APIs.
1414

1515
## Aggregations
@@ -23,11 +23,11 @@ For example, for each existing `age` value:
2323
* `31`: 18 results
2424
* etc.
2525

26-
In Elasticsearch, there are several types of aggregations available. React-SearchKit comes out of the box with a component that implements [Bucket Terms Aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html), but any other aggregation should be easy to implement.
26+
In OpenSearch, there are several types of aggregations available. React-SearchKit comes out of the box with a component that implements [Bucket Terms Aggregations](https://opensearch.org/docs/latest/aggregations/bucket/terms/), but any other aggregation should be easy to implement.
2727

2828
## Bucket aggregations
2929

30-
The `<BucketAggregation>` component defines the name of the aggregation to request to the backend or Elasticsearch and the field to compute the aggregations on.
30+
The `<BucketAggregation>` component defines the name of the aggregation to request to the backend or OpenSearch and the field to compute the aggregations on.
3131
For example:
3232

3333
```jsx
@@ -41,7 +41,7 @@ For example:
4141

4242
> It is your responsibility to create the search request to your backend taking into account the configured aggregations.
4343
44-
The `results` state should then contains aggregations results in the object `aggregations`. The `<BucketAggregation>` component expects the Elasticsearch format:
44+
The `results` state should then contains aggregations results in the object `aggregations`. The `<BucketAggregation>` component expects the OpenSearch format:
4545

4646
```json
4747
{

docs/docs/getting_started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class App extends Component {
7878
}
7979
```
8080

81-
> Note: `React-SearchKit` comes out of the box with support to ElasticSearch 7 and [Invenio](https://inveniosoftware.org) REST APIs. To connect your own REST APIs, you can override the default configuration or provide your own adapter for your backend. Follow the next steps of this guide for detailed instructions on how to do it.
81+
> Note: `React-SearchKit` comes out of the box with support to OpenSearch 2 and [Invenio](https://inveniosoftware.org) REST APIs. To connect your own REST APIs, you can override the default configuration or provide your own adapter for your backend. Follow the next steps of this guide for detailed instructions on how to do it.
8282
8383
## Add the first component
8484

docs/docs/main_concepts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ API responses will update this part of the state. Components that are connected
9595

9696
The API layer is composed of:
9797

98-
* `SearchAPI`: adapter for HTTP requests. Available in 2 flavors, for Elasticsearch and Invenio, it is responsible of serializing the `query` state to search requests for your REST APIs and serialize back responses to mutate the `results` state.
98+
* `SearchAPI`: adapter for HTTP requests. Available in 2 flavors, for OpenSearch and Invenio, it is responsible of serializing the `query` state to search requests for your REST APIs and serialize back responses to mutate the `results` state.
9999
* `UrlHandlerApi`: an object capable of serializing the `query` state to the URL query string and vice versa, very useful for deep linking.
100100

101101
> Note: given the structure of the Redux state, responses serialization must be adapted to the `results` state structure.

docs/website/pages/en/index.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
* under the terms of the MIT License; see LICENSE file for more details.
77
*/
88

9-
const React = require('react');
9+
const React = require("react");
10+
11+
const CompLibrary = require("../../core/CompLibrary.js");
1012

11-
const CompLibrary = require('../../core/CompLibrary.js');
1213
const Container = CompLibrary.Container;
1314
const GridBlock = CompLibrary.GridBlock;
1415

15-
const siteConfig = require(process.cwd() + '/siteConfig.js');
16+
const siteConfig = require(process.cwd() + "/siteConfig.js");
1617

1718
class Button extends React.Component {
1819
render() {
@@ -27,7 +28,7 @@ class Button extends React.Component {
2728
}
2829

2930
Button.defaultProps = {
30-
target: '_self',
31+
target: "_self",
3132
};
3233

3334
class Header extends React.Component {
@@ -55,13 +56,13 @@ class Header extends React.Component {
5556
</div>
5657
</div>
5758
</div>
58-
<div className="githubButton" style={{ minHeight: '20px' }}>
59+
<div className="githubButton" style={{ minHeight: "20px" }}>
5960
<a
6061
className="github-button"
6162
href={this.props.config.repoUrl}
6263
data-icon="octicon-star"
6364
data-count-href="/inveniosoftware/react-searchkit/stargazers"
64-
data-show-count={true}
65+
data-show-count
6566
data-count-aria-label="# stargazers on GitHub"
6667
aria-label="Star inveniosoftware/react-searchkit on GitHub"
6768
>
@@ -82,31 +83,31 @@ class Home extends React.Component {
8283
<div>
8384
<Header config={siteConfig} />
8485
<div className="mainContainer">
85-
<Container padding={['bottom', 'top']} background="light">
86+
<Container padding={["bottom", "top"]} background="light">
8687
<GridBlock
8788
align="center"
8889
layout="threeColumn"
8990
contents={[
9091
{
91-
title: 'Ready To Use',
92+
title: "Ready To Use",
9293
content: `Compose your search UI choosing between any of the available components. Override the
9394
default look and feel of each component and provide yours.`,
9495
},
9596
{
96-
title: 'Fully Configurable',
97-
content: `Use React-SearchKit with your search REST API endpoint or Elasticsearch by providing your
97+
title: "Fully Configurable",
98+
content: `Use React-SearchKit with your search REST API endpoint or OpenSearch by providing your
9899
configuration or implementation. Customize deep linking and integrate with React Router.`,
99100
},
100101
{
101-
title: 'Extensible',
102+
title: "Extensible",
102103
content:
103-
'Create new components in a simple way and plug them to the other already available ones.',
104+
"Create new components in a simple way and plug them to the other already available ones.",
104105
},
105106
]}
106107
/>
107108
</Container>
108-
<Container padding={['all']}>
109-
<div style={{ textAlign: 'center' }}>
109+
<Container padding={["all"]}>
110+
<div style={{ textAlign: "center" }}>
110111
<img
111112
src={`${siteConfig.baseUrl}img/screenshot.png`}
112113
alt="Screenshot"

0 commit comments

Comments
 (0)