Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data.search] Add search session methods to search service contract #87966

Merged
merged 32 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c22024f
[data.search] Add search session methods to search service contract
lukasolson Jan 12, 2021
1046c54
Merge branch 'master' into search-session-api
lukasolson Jan 15, 2021
7040716
Fix types
lukasolson Jan 15, 2021
eeddf84
Fix tests and switch to cancel
lukasolson Jan 15, 2021
f09eb38
Update docs
lukasolson Jan 15, 2021
e6124af
Merge branch 'master' into search-session-api
lukasolson Jan 19, 2021
e160019
Fix types/tests
lukasolson Jan 19, 2021
3c08c3d
Fix tests
lukasolson Jan 19, 2021
0cd92ed
Update status of SO before cancelling search requests
lukasolson Jan 19, 2021
f1a1d0b
Add API integration test
lukasolson Jan 19, 2021
552e545
Merge branch 'master' into search-session-api
lukasolson Jan 20, 2021
ee6e337
Merge branch 'master' into search-session-api
lukasolson Jan 25, 2021
32315b7
Fix types
lukasolson Jan 25, 2021
542de95
Update expiration route to use config defaultExpiration
lukasolson Jan 25, 2021
5b22249
Fix test
lukasolson Jan 25, 2021
66420b4
Update docs
lukasolson Jan 25, 2021
8a5e3d3
New logic for extend
lukasolson Jan 26, 2021
71582c7
Remove declare module
lukasolson Jan 26, 2021
65840b3
Review feedback
lukasolson Jan 26, 2021
fdb940b
Merge branch 'master' of github.com:elastic/kibana into pr/87966
Jan 27, 2021
b2bce4b
fix ts
Jan 27, 2021
50081b5
Merge branch 'master' into search-session-api
lukasolson Jan 28, 2021
e24181c
Remove test that is no longer valid
lukasolson Jan 28, 2021
08ed572
Merge remote-tracking branch 'origin/search-session-api' into search-…
lukasolson Jan 28, 2021
44ef260
Merge branch 'master' into search-session-api
lukasolson Jan 28, 2021
99b4ca0
Merge branch 'master' into search-session-api
lukasolson Feb 1, 2021
99dc347
Fix undefined bug
lukasolson Feb 1, 2021
e582910
Merge branch 'master' into search-session-api
lukasolson Feb 2, 2021
fbfc1b1
Fix types
lukasolson Feb 2, 2021
5c564c2
Merge branch 'master' of github.com:elastic/kibana into pr/87966
Feb 3, 2021
3eb8f01
Use DataRequestHandlerContext in maps
Feb 3, 2021
6462da6
ts
Feb 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [ISearchSessionService](./kibana-plugin-plugins-data-server.isearchsessionservice.md) &gt; [asScopedProvider](./kibana-plugin-plugins-data-server.isearchsessionservice.asscopedprovider.md)

## ISearchSessionService.asScopedProvider property

<b>Signature:</b>

```typescript
asScopedProvider: (core: CoreStart) => (request: KibanaRequest) => IScopedSearchSessionsClient<T>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [ISearchSessionService](./kibana-plugin-plugins-data-server.isearchsessionservice.md)

## ISearchSessionService interface

<b>Signature:</b>

```typescript
export interface ISearchSessionService<T = unknown>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [asScopedProvider](./kibana-plugin-plugins-data-server.isearchsessionservice.asscopedprovider.md) | <code>(core: CoreStart) =&gt; (request: KibanaRequest) =&gt; IScopedSearchSessionsClient&lt;T&gt;</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
asScoped: (request: KibanaRequest) => ISearchClient;
asScoped: (request: KibanaRequest) => IScopedSearchClient;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ISearchStart<SearchStrategyRequest extends IKibanaSearchRequest
| Property | Type | Description |
| --- | --- | --- |
| [aggs](./kibana-plugin-plugins-data-server.isearchstart.aggs.md) | <code>AggsStart</code> | |
| [asScoped](./kibana-plugin-plugins-data-server.isearchstart.asscoped.md) | <code>(request: KibanaRequest) =&gt; ISearchClient</code> | |
| [asScoped](./kibana-plugin-plugins-data-server.isearchstart.asscoped.md) | <code>(request: KibanaRequest) =&gt; IScopedSearchClient</code> | |
| [getSearchStrategy](./kibana-plugin-plugins-data-server.isearchstart.getsearchstrategy.md) | <code>(name?: string) =&gt; ISearchStrategy&lt;SearchStrategyRequest, SearchStrategyResponse&gt;</code> | Get other registered search strategies by name (or, by default, the Elasticsearch strategy). For example, if a new strategy needs to use the already-registered ES search strategy, it can use this function to accomplish that. |
| [searchSource](./kibana-plugin-plugins-data-server.isearchstart.searchsource.md) | <code>{</code><br/><code> asScoped: (request: KibanaRequest) =&gt; Promise&lt;ISearchStartSearchSource&gt;;</code><br/><code> }</code> | |

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
| [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) | |
| [OptionedParamType](./kibana-plugin-plugins-data-server.optionedparamtype.md) | |
| [Plugin](./kibana-plugin-plugins-data-server.plugin.md) | |
| [SessionService](./kibana-plugin-plugins-data-server.sessionservice.md) | The OSS session service. See data\_enhanced in X-Pack for the search session service. |

## Enumerations

Expand Down Expand Up @@ -45,20 +44,18 @@
| --- | --- |
| [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) | A global list of the expression function definitions for each agg type function. |
| [AggParamOption](./kibana-plugin-plugins-data-server.aggparamoption.md) | |
| [DataApiRequestHandlerContext](./kibana-plugin-plugins-data-server.dataapirequesthandlercontext.md) | |
| [EsQueryConfig](./kibana-plugin-plugins-data-server.esqueryconfig.md) | |
| [FieldDescriptor](./kibana-plugin-plugins-data-server.fielddescriptor.md) | |
| [FieldFormatConfig](./kibana-plugin-plugins-data-server.fieldformatconfig.md) | |
| [IEsSearchRequest](./kibana-plugin-plugins-data-server.iessearchrequest.md) | |
| [IFieldSubType](./kibana-plugin-plugins-data-server.ifieldsubtype.md) | |
| [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) | |
| [IndexPatternAttributes](./kibana-plugin-plugins-data-server.indexpatternattributes.md) | Interface for an index pattern saved object |
| [IScopedSessionService](./kibana-plugin-plugins-data-server.iscopedsessionservice.md) | |
| [ISearchOptions](./kibana-plugin-plugins-data-server.isearchoptions.md) | |
| [ISearchSessionService](./kibana-plugin-plugins-data-server.isearchsessionservice.md) | |
| [ISearchSetup](./kibana-plugin-plugins-data-server.isearchsetup.md) | |
| [ISearchStart](./kibana-plugin-plugins-data-server.isearchstart.md) | |
| [ISearchStrategy](./kibana-plugin-plugins-data-server.isearchstrategy.md) | Search strategy interface contains a search method that takes in a request and returns a promise that resolves to a response. |
| [ISessionService](./kibana-plugin-plugins-data-server.isessionservice.md) | |
| [KueryNode](./kibana-plugin-plugins-data-server.kuerynode.md) | |
| [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md) | |
| [PluginSetup](./kibana-plugin-plugins-data-server.pluginsetup.md) | |
Expand Down Expand Up @@ -110,5 +107,6 @@
| [KibanaContext](./kibana-plugin-plugins-data-server.kibanacontext.md) | |
| [ParsedInterval](./kibana-plugin-plugins-data-server.parsedinterval.md) | |
| [Query](./kibana-plugin-plugins-data-server.query.md) | |
| [SearchRequestHandlerContext](./kibana-plugin-plugins-data-server.searchrequesthandlercontext.md) | |
| [TimeRange](./kibana-plugin-plugins-data-server.timerange.md) | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SearchRequestHandlerContext](./kibana-plugin-plugins-data-server.searchrequesthandlercontext.md)

## SearchRequestHandlerContext type

<b>Signature:</b>

```typescript
export declare type SearchRequestHandlerContext = IScopedSearchClient;
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export interface SearchStrategyDependencies
| --- | --- | --- |
| [esClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.esclient.md) | <code>IScopedClusterClient</code> | |
| [savedObjectsClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | |
| [searchSessionsClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.searchsessionsclient.md) | <code>IScopedSearchSessionsClient</code> | |
| [uiSettingsClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.uisettingsclient.md) | <code>IUiSettingsClient</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SearchStrategyDependencies](./kibana-plugin-plugins-data-server.searchstrategydependencies.md) &gt; [searchSessionsClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.searchsessionsclient.md)

## SearchStrategyDependencies.searchSessionsClient property

<b>Signature:</b>

```typescript
searchSessionsClient: IScopedSearchSessionsClient;
```

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 2 additions & 5 deletions examples/search_examples/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import type {
CoreStart,
Plugin,
Logger,
RequestHandlerContext,
} from 'src/core/server';

import type { DataApiRequestHandlerContext } from 'src/plugins/data/server';
import type { DataRequestHandlerContext } from 'src/plugins/data/server';

import {
SearchExamplesPluginSetup,
Expand Down Expand Up @@ -45,9 +44,7 @@ export class SearchExamplesPlugin
deps: SearchExamplesPluginSetupDeps
) {
this.logger.debug('search_examples: Setup');
const router = core.http.createRouter<
RequestHandlerContext & { search: DataApiRequestHandlerContext }
>();
const router = core.http.createRouter<DataRequestHandlerContext>();

core.getStartServices().then(([_, depsStart]) => {
const myStrategy = mySearchStrategyProvider(depsStart.data);
Expand Down
8 changes: 3 additions & 5 deletions examples/search_examples/server/routes/register_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
* Public License, v 1.
*/

import type { IRouter, RequestHandlerContext } from 'kibana/server';
import { DataApiRequestHandlerContext } from 'src/plugins/data/server';
import type { IRouter } from 'kibana/server';
import { DataRequestHandlerContext } from 'src/plugins/data/server';
import { registerServerSearchRoute } from './server_search_route';

export function registerRoutes(
router: IRouter<RequestHandlerContext & { search: DataApiRequestHandlerContext }>
) {
export function registerRoutes(router: IRouter<DataRequestHandlerContext>) {
registerServerSearchRoute(router);
}
8 changes: 3 additions & 5 deletions examples/search_examples/server/routes/server_search_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
import { IEsSearchRequest } from 'src/plugins/data/server';
import { schema } from '@kbn/config-schema';
import { IEsSearchResponse } from 'src/plugins/data/common';
import type { DataApiRequestHandlerContext } from 'src/plugins/data/server';
import type { IRouter, RequestHandlerContext } from 'src/core/server';
import type { DataRequestHandlerContext } from 'src/plugins/data/server';
import type { IRouter } from 'src/core/server';
import { SERVER_SEARCH_ROUTE_PATH } from '../../common';

export function registerServerSearchRoute(
router: IRouter<RequestHandlerContext & { search: DataApiRequestHandlerContext }>
) {
export function registerServerSearchRoute(router: IRouter<DataRequestHandlerContext>) {
router.get(
{
path: SERVER_SEARCH_ROUTE_PATH,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/search/session/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function getSessionsClientMock(): jest.Mocked<ISessionsClient> {
create: jest.fn(),
find: jest.fn(),
update: jest.fn(),
extend: jest.fn(),
delete: jest.fn(),
};
}
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/data/public/search/session/sessions_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export class SessionsClient {
});
}

public extend(sessionId: string, keepAlive: string): Promise<SavedObjectsFindResponse> {
return this.http!.post(`/internal/session/${encodeURIComponent(sessionId)}/_extend`, {
body: JSON.stringify({ keepAlive }),
lukasolson marked this conversation as resolved.
Show resolved Hide resolved
});
}

public delete(sessionId: string): Promise<void> {
return this.http!.delete(`/internal/session/${encodeURIComponent(sessionId)}`);
}
Expand Down
7 changes: 3 additions & 4 deletions src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,9 @@ export {
searchUsageObserver,
shimAbortSignal,
SearchUsage,
SessionService,
ISessionService,
IScopedSessionService,
DataApiRequestHandlerContext,
SearchSessionService,
ISearchSessionService,
SearchRequestHandlerContext,
DataRequestHandlerContext,
} from './search';

Expand Down
Loading