Skip to content

Commit

Permalink
Merge branch 'main' into refactor-controls-services_2022-08-10
Browse files Browse the repository at this point in the history
  • Loading branch information
Heenawter authored Aug 23, 2022
2 parents 9c26a01 + fe646b2 commit 702144b
Show file tree
Hide file tree
Showing 36 changed files with 416 additions and 1,166 deletions.
2 changes: 1 addition & 1 deletion docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Set this property to `false` to prevent the filter editor and KQL autocomplete
from suggesting values for fields.

[[autocomplete-valuesuggestionmethod]]`autocomplete:valueSuggestionMethod`::
When set to `terms_enum`, autocomplete uses the terms enum API for value suggestions. Kibana returns results faster, but suggestions are approximate, sorted alphabetically, and can be outside the selected time range.
When set to `terms_enum`, autocomplete uses the terms enum API for value suggestions. Kibana returns results faster, but suggestions are approximate, sorted alphabetically, and can be outside the selected time range. (Note that this API is incompatible with {ref}/document-level-security.html[Document-Level-Security].)
When set to `terms_agg`, Kibana uses a terms aggregation for value suggestions, which is
slower, but suggestions include all values that optionally match your time range and are sorted by popularity.

Expand Down
5 changes: 3 additions & 2 deletions src/plugins/data/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,9 @@ export function getUiSettings(
description: i18n.translate('data.advancedSettings.autocompleteValueSuggestionMethodText', {
defaultMessage:
'The method used for querying suggestions for values in KQL autocomplete. Select terms_enum to use the ' +
'Elasticsearch terms enum API for improved autocomplete suggestion performance. Select terms_agg to use an ' +
'Elasticsearch terms aggregation. {learnMoreLink}',
'Elasticsearch terms enum API for improved autocomplete suggestion performance. (Note that terms_enum is ' +
'incompatible with Document Level Security.) Select terms_agg to use an Elasticsearch terms aggregation. ' +
'{learnMoreLink}',
values: {
learnMoreLink:
`<a href=${docLinks.links.kibana.autocompleteSuggestions} target="_blank" rel="noopener">` +
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/enterprise_search/common/types/indices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Crawler } from './crawler';
export interface ElasticsearchIndex {
count: number; // Elasticsearch _count
health?: HealthStatus;
hidden: boolean;
name: IndexName;
status?: IndicesStatsIndexMetadataState;
total: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const mockElasticsearchIndices: ElasticsearchIndexWithPrivileges[] = [
{
count: 0,
health: 'yellow',
hidden: false,
status: 'open',
name: 'search-my-index-1',
uuid: 'ydlR_QQJTeyZP66tzQSmMQ',
Expand All @@ -56,6 +57,7 @@ export const mockElasticsearchIndices: ElasticsearchIndexWithPrivileges[] = [
{
count: 100,
health: 'green',
hidden: false,
status: 'open',
name: 'my-index-2',
uuid: '4dlR_QQJTe2ZP6qtzQSmMQ',
Expand All @@ -74,6 +76,7 @@ export const mockElasticsearchIndices: ElasticsearchIndexWithPrivileges[] = [
{
count: 100,
health: 'green',
hidden: false,
status: 'open',
name: 'search-my-index-2',
uuid: '4dlR_QQJTe2ZP6qtzQSmMQ',
Expand All @@ -92,6 +95,7 @@ export const mockElasticsearchIndices: ElasticsearchIndexWithPrivileges[] = [
{
count: 100,
health: 'green',
hidden: false,
status: 'open',
name: 'alias-my-index-2',
uuid: '4dlR_QQJTe2ZP6qtzQSmMQ',
Expand All @@ -110,6 +114,7 @@ export const mockElasticsearchIndices: ElasticsearchIndexWithPrivileges[] = [
{
count: 100,
health: 'green',
hidden: false,
status: 'open',
name: 'index-without-read-privilege',
uuid: '4dlR_QQJTe2ZP6qtzQSmMQ',
Expand All @@ -128,6 +133,7 @@ export const mockElasticsearchIndices: ElasticsearchIndexWithPrivileges[] = [
{
count: 100,
health: 'green',
hidden: false,
status: 'open',
name: 'index-without-manage-privilege',
uuid: '4dlR_QQJTe2ZP6qtzQSmMQ',
Expand All @@ -146,6 +152,7 @@ export const mockElasticsearchIndices: ElasticsearchIndexWithPrivileges[] = [
{
count: 100,
health: 'green',
hidden: false,
status: 'open',
name: 'alias-without-manage-privilege',
uuid: '4dlR_QQJTe2ZP6qtzQSmMQ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useLocation } from 'react-router-dom';
import { Location } from 'history';
import { useActions, useValues } from 'kea';

import { ESINDEX_QUERY_PARAMETER } from '../../../shared/constants';
import { parseQueryParams } from '../../../shared/query_params';
import { ENGINES_TITLE } from '../engines';
import { AppSearchPageTemplate } from '../layout';
Expand All @@ -25,15 +26,19 @@ import { SelectEngineType } from './select_engine_type';

export const EngineCreation: React.FC = () => {
const { search } = useLocation() as Location;
const { method } = parseQueryParams(search);
const { method, ...params } = parseQueryParams(search);

const { engineType, currentEngineCreationStep } = useValues(EngineCreationLogic);
const { setIngestionMethod } = useActions(EngineCreationLogic);
const { setIngestionMethod, initializeWithESIndex } = useActions(EngineCreationLogic);

useEffect(() => {
if (typeof method === 'string') {
setIngestionMethod(method);
}
const esIndexParam = params[ESINDEX_QUERY_PARAMETER];
if (typeof esIndexParam === 'string') {
initializeWithESIndex(esIndexParam);
}
}, []);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface EngineCreationActions {
setSelectedIndex(selectedIndexName: string): { selectedIndexName: string };
setEngineType(engineType: EngineType): { engineType: EngineType };
setIsAliasAllowed(isAliasAllowed: boolean): { isAliasAllowed: boolean };
initializeWithESIndex(indexName: string): { indexName: string };
}

interface EngineCreationValues {
Expand Down Expand Up @@ -82,6 +83,7 @@ export const EngineCreationLogic = kea<MakeLogicType<EngineCreationValues, Engin
setEngineType: (engineType) => ({ engineType }),
setCreationStep: (currentEngineCreationStep) => currentEngineCreationStep,
setIsAliasAllowed: (isAliasAllowed) => ({ isAliasAllowed }),
initializeWithESIndex: (indexName) => ({ indexName }),
},
reducers: {
ingestionMethod: [
Expand Down Expand Up @@ -118,6 +120,10 @@ export const EngineCreationLogic = kea<MakeLogicType<EngineCreationValues, Engin
? ''
: `search-${selectedIndexName}-alias`;
},
initializeWithESIndex: (_, { indexName }) =>
indexName.length === 0 || indexName.startsWith('search-')
? ''
: `search-${indexName}-alias`,
},
],
isAliasAllowed: [
Expand Down Expand Up @@ -145,18 +151,21 @@ export const EngineCreationLogic = kea<MakeLogicType<EngineCreationValues, Engin
{
setSelectedIndex: (_, { selectedIndexName }) => selectedIndexName,
onSubmitError: () => '',
initializeWithESIndex: (_, { indexName }) => indexName,
},
],
engineType: [
'appSearch',
{
setEngineType: (_, { engineType }) => engineType,
initializeWithESIndex: () => 'elasticsearch',
},
],
currentEngineCreationStep: [
EngineCreationSteps.SelectStep,
{
setCreationStep: (_, currentEngineCreationStep) => currentEngineCreationStep,
initializeWithESIndex: () => EngineCreationSteps.ConfigureStep,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ElasticsearchIndexWithIngestion } from '../../../../common/types/indice
export const indices: ElasticsearchIndexWithIngestion[] = [
{
count: 1,
hidden: false,
name: 'api',
total: {
docs: {
Expand Down Expand Up @@ -41,6 +42,7 @@ export const indices: ElasticsearchIndexWithIngestion[] = [
sync_now: false,
},
count: 1,
hidden: false,
name: 'connector',
total: {
docs: {
Expand All @@ -56,6 +58,7 @@ export const indices: ElasticsearchIndexWithIngestion[] = [
id: '3',
index_name: 'crawler',
},
hidden: false,
name: 'crawler',
total: {
docs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const apiIndex: ApiViewIndex = {
ingestionMethod: IngestionMethod.API,
ingestionStatus: IngestionStatus.CONNECTED,
lastUpdated: null,
hidden: false,
name: 'api',
total: {
docs: {
Expand Down Expand Up @@ -50,6 +51,7 @@ export const connectorIndex: ConnectorViewIndex = {
sync_now: false,
},
count: 1,
hidden: false,
ingestionMethod: IngestionMethod.CONNECTOR,
ingestionStatus: IngestionStatus.INCOMPLETE,
lastUpdated: 'never',
Expand All @@ -68,6 +70,7 @@ export const crawlerIndex: CrawlerViewIndex = {
id: '3',
index_name: 'crawler',
},
hidden: false,
ingestionMethod: IngestionMethod.CRAWLER,
ingestionStatus: IngestionStatus.INCOMPLETE,
lastUpdated: null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';

import { EuiBetaBadge, EuiContextMenuItem, EuiText, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';

import { i18n } from '@kbn/i18n';

import { APP_SEARCH_PLUGIN } from '../../../../../../../common/constants';
import { ENGINE_CREATION_PATH } from '../../../../../app_search/routes';
import { ESINDEX_QUERY_PARAMETER } from '../../../../../shared/constants';
import { generateEncodedPath } from '../../../../../shared/encode_path_params';
import { KibanaLogic } from '../../../../../shared/kibana';

export interface CreateEngineMenuItemProps {
indexName?: string;
isHiddenIndex?: boolean;
}

export const CreateEngineMenuItem: React.FC<CreateEngineMenuItemProps> = ({
indexName,
isHiddenIndex,
}) => {
const engineCreationPath = !indexName
? `${APP_SEARCH_PLUGIN.URL}${ENGINE_CREATION_PATH}`
: generateEncodedPath(`${APP_SEARCH_PLUGIN.URL}${ENGINE_CREATION_PATH}?:indexKey=:indexName`, {
indexKey: ESINDEX_QUERY_PARAMETER,
indexName,
});

return (
<EuiFlexGroup alignItems="center" gutterSize="xs">
<EuiFlexItem>
<EuiContextMenuItem
size="s"
icon="plusInCircle"
onClick={() => {
KibanaLogic.values.navigateToUrl(engineCreationPath, {
shouldNotCreateHref: true,
});
}}
disabled={isHiddenIndex}
>
<EuiText>
<p>
{i18n.translate('xpack.enterpriseSearch.content.index.searchEngines.createEngine', {
defaultMessage: 'Create an App Search engine',
})}
</p>
</EuiText>
</EuiContextMenuItem>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ paddingTop: '.125rem' }}>
<EuiBetaBadge label="Beta" size="s" />
</EuiFlexItem>
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ import { SyncButton } from './sync_button';
export const getHeaderActions = (indexData?: ElasticsearchIndexWithIngestion) => [
...(isCrawlerIndex(indexData) ? [<CrawlerStatusIndicator />] : []),
...(isConnectorIndex(indexData) ? [<SyncButton />] : []),
<SearchEnginesPopover />,
<SearchEnginesPopover indexName={indexData?.name} isHiddenIndex={indexData?.hidden} />,
];
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,26 @@ import {
EuiContextMenuPanel,
EuiContextMenuItem,
EuiText,
EuiToolTip,
} from '@elastic/eui';

import { i18n } from '@kbn/i18n';

import { APP_SEARCH_PLUGIN } from '../../../../../../../common/constants';
import { ENGINE_CREATION_PATH } from '../../../../../app_search/routes';
import { KibanaLogic } from '../../../../../shared/kibana';

import { CreateEngineMenuItem } from './create_engine_menu_item';
import { SearchEnginesPopoverLogic } from './search_engines_popover_logic';

export const SearchEnginesPopover: React.FC = () => {
export interface SearchEnginesPopoverProps {
indexName?: string;
isHiddenIndex?: boolean;
}

export const SearchEnginesPopover: React.FC<SearchEnginesPopoverProps> = ({
indexName,
isHiddenIndex,
}) => {
const { isSearchEnginesPopoverOpen } = useValues(SearchEnginesPopoverLogic);
const { toggleSearchEnginesPopover } = useActions(SearchEnginesPopoverLogic);

Expand Down Expand Up @@ -60,22 +69,20 @@ export const SearchEnginesPopover: React.FC = () => {
</p>
</EuiText>
</EuiContextMenuItem>,
<EuiContextMenuItem
icon="plusInCircle"
onClick={() => {
KibanaLogic.values.navigateToUrl(APP_SEARCH_PLUGIN.URL + ENGINE_CREATION_PATH, {
shouldNotCreateHref: true,
});
}}
>
<EuiText>
<p>
{i18n.translate('xpack.enterpriseSearch.content.index.searchEngines.createEngine', {
defaultMessage: 'Create a new App Search engine',
})}
</p>
</EuiText>
</EuiContextMenuItem>,
isHiddenIndex ? (
<EuiToolTip
content={i18n.translate(
'xpack.enterpriseSearch.content.index.searchEngines.createEngineDisabledTooltip',
{
defaultMessage: 'You cannot create engines from hidden indices.',
}
)}
>
<CreateEngineMenuItem indexName={indexName} isHiddenIndex={isHiddenIndex} />
</EuiToolTip>
) : (
<CreateEngineMenuItem indexName={indexName} isHiddenIndex={isHiddenIndex} />
),
]}
/>
</EuiPopover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

export * from './actions';
export * from './labels';
export * from './query_params';
export * from './tables';
export * from './units';
export { DEFAULT_META } from './default_meta';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const ESINDEX_QUERY_PARAMETER = 'esindex';
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const mockSingleIndexStatsResponse = {
indices: {
'search-regular-index': {
health: 'green',
hidden: false,
status: 'open',
total: {
docs: {
Expand Down Expand Up @@ -115,6 +116,7 @@ export const getIndexReturnValue = (indexName: string) => {
alias: indexName.startsWith('alias') || indexName.startsWith('search-alias'),
count: 100,
name: indexName,
hidden: indexName.includes('hidden'),
privileges: { manage: true, read: true },
total: {
...mockMultiStatsResponse.indices[indexName].total,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('fetchIndex lib function', () => {
indices: {
index_name: {
health: 'green',
hidden: false,
size: new ByteSizeValue(108000).toString(),
status: 'open',
total: {
Expand All @@ -63,6 +64,7 @@ describe('fetchIndex lib function', () => {
aliases: [],
count: 100,
health: 'green',
hidden: false,
name: 'index_name',
status: 'open',
total: {
Expand Down
Loading

0 comments on commit 702144b

Please sign in to comment.