Skip to content
This repository was archived by the owner on Aug 31, 2022. It is now read-only.

Commit f7dcd15

Browse files
gurbirkalsiportante
authored andcommitted
Update indices query with faster call for concise list of all indices
within cluster
1 parent 61eb773 commit f7dcd15

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

mock/api.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ export const generateMockControllerAggregation = {
2424

2525
const datastoreConfig = config['/dev/datastoreConfig'];
2626
const prefix = datastoreConfig.prefix + datastoreConfig.run_index.slice(0, -1);
27-
export const mockIndices = [
28-
{
29-
index: `${prefix}.0000-00-00`,
30-
},
31-
{
32-
index: `${prefix}.0000-00-01`,
33-
},
34-
];
27+
export const mockIndices = {
28+
[`${prefix}.0000-00-00`]: {},
29+
[`${prefix}.0000-00-01`]: {},
30+
};
3531

3632
export const mockResults = {
3733
hits: {

src/e2e/controllers.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ beforeAll(async () => {
2020
headers: { 'Access-Control-Allow-Origin': '*' },
2121
body: JSON.stringify(generateMockControllerAggregation),
2222
});
23-
} else if (request.method() === 'GET' && request.url().includes('indices')) {
23+
} else if (request.method() === 'GET' && request.url().includes('aliases')) {
2424
request.respond({
2525
status: 200,
2626
contentType: 'application/json',

src/e2e/results.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ beforeAll(async () => {
2020
headers: { 'Access-Control-Allow-Origin': '*' },
2121
body: JSON.stringify(generateMockControllerAggregation),
2222
});
23-
} else if (request.method() === 'GET' && request.url().includes('indices')) {
23+
} else if (request.method() === 'GET' && request.url().includes('aliases')) {
2424
request.respond({
2525
status: 200,
2626
contentType: 'application/json',

src/e2e/search.e2e.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ beforeAll(async () => {
2020
headers: { 'Access-Control-Allow-Origin': '*' },
2121
body: JSON.stringify(mockSearch),
2222
});
23-
} else if (request.method() === 'GET' && request.url().includes('indices')) {
23+
} else if (request.method() === 'GET' && request.url().includes('aliases')) {
2424
request.respond({
2525
status: 200,
2626
contentType: 'application/json',
@@ -51,7 +51,11 @@ describe('search page component', () => {
5151
'.ant-select:nth-child(1) > .ant-select-selection > .ant-select-selection__rendered > ul > .ant-select-selection__choice',
5252
elem => elem.getAttribute('title')
5353
);
54-
expect(testMonth).toBe(mockIndices[0].index.split('.').pop());
54+
expect(testMonth).toBe(
55+
Object.keys(mockIndices)[0]
56+
.split('.')
57+
.pop()
58+
);
5559
});
5660

5761
test('should load mappings', async () => {

src/models/datastore.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export default {
2828
const indices = [];
2929

3030
const prefix = datastoreConfig.prefix + datastoreConfig.run_index.slice(0, -1);
31-
response.forEach(index => {
32-
if (index.index.includes(prefix)) {
33-
indices.push(index.index.split('.').pop());
31+
Object.keys(response).forEach(index => {
32+
if (index.includes(prefix)) {
33+
indices.push(index.split('.').pop());
3434
}
3535
});
3636

src/services/datastore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function queryDatastoreConfig() {
2929
export async function queryMonthIndices(params) {
3030
const { datastoreConfig } = params;
3131

32-
const endpoint = `${datastoreConfig.elasticsearch}/_cat/indices?format=json&pretty=true`;
32+
const endpoint = `${datastoreConfig.elasticsearch}/_aliases`;
3333

3434
return request.get(endpoint);
3535
}

0 commit comments

Comments
 (0)