Skip to content

Commit

Permalink
include frozen index (#118555)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
2 people authored and dmlemeshko committed Nov 29, 2021
1 parent f6915ca commit f2eba4a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion x-pack/plugins/lens/server/routes/existing_fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ export async function existingFieldsRoute(setup: CoreSetup<PluginStartContract>,
},
},
async (context, req, res) => {
const [{ savedObjects, elasticsearch }, { data }] = await setup.getStartServices();
const [{ savedObjects, elasticsearch, uiSettings }, { data }] =
await setup.getStartServices();
const savedObjectsClient = savedObjects.getScopedClient(req);
const includeFrozen: boolean = await uiSettings
.asScopedToClient(savedObjectsClient)
.get(UI_SETTINGS.SEARCH_INCLUDE_FROZEN);
const esClient = elasticsearch.client.asScoped(req).asCurrentUser;
try {
return res.ok({
Expand All @@ -66,6 +70,7 @@ export async function existingFieldsRoute(setup: CoreSetup<PluginStartContract>,
esClient
),
context,
includeFrozen,
}),
});
} catch (e) {
Expand Down Expand Up @@ -103,6 +108,7 @@ async function fetchFieldExistence({
fromDate,
toDate,
timeFieldName,
includeFrozen,
}: {
indexPatternId: string;
context: RequestHandlerContext;
Expand All @@ -111,6 +117,7 @@ async function fetchFieldExistence({
fromDate?: string;
toDate?: string;
timeFieldName?: string;
includeFrozen: boolean;
}) {
const metaFields: string[] = await context.core.uiSettings.client.get(UI_SETTINGS.META_FIELDS);
const indexPattern = await indexPatternsService.get(indexPatternId);
Expand All @@ -124,6 +131,7 @@ async function fetchFieldExistence({
index: indexPattern.title,
timeFieldName: timeFieldName || indexPattern.timeFieldName,
fields,
includeFrozen,
});

return {
Expand Down Expand Up @@ -158,6 +166,7 @@ async function fetchIndexPatternStats({
fromDate,
toDate,
fields,
includeFrozen,
}: {
client: ElasticsearchClient;
index: string;
Expand All @@ -166,6 +175,7 @@ async function fetchIndexPatternStats({
fromDate?: string;
toDate?: string;
fields: Field[];
includeFrozen: boolean;
}) {
const filter =
timeFieldName && fromDate && toDate
Expand Down Expand Up @@ -193,6 +203,7 @@ async function fetchIndexPatternStats({
const { body: result } = await client.search(
{
index,
...(includeFrozen ? { ignore_throttled: false } : {}),
body: {
size: SAMPLE_SIZE,
query,
Expand Down

0 comments on commit f2eba4a

Please sign in to comment.