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

[Search] Server strategy example #71679

Merged
merged 38 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cf412aa
Server strategy example
Jul 14, 2020
0f22458
Add tsconfig
Jul 15, 2020
b9a5efe
Docs + remove unused sample code
Jul 15, 2020
f7cd473
Fix test naming of arguments
Jul 15, 2020
f7f51c7
ts
Jul 15, 2020
170bae5
ts fix
Jul 15, 2020
47d7302
Add filters and query input selector
Jul 16, 2020
a84eafb
Update examples/search_examples/public/components/app.tsx
lizozom Jul 15, 2020
ee3ff70
Use new service
Jul 16, 2020
79f42e0
exapmle plugin ts
Jul 22, 2020
d4ec2ee
unsubscribe + use timefilter
Jul 23, 2020
b6c9cba
typo
Jul 27, 2020
e8ad12b
docs
Jul 29, 2020
1f87741
Merge branch 'master' of github.com:elastic/kibana into search/server…
Jul 30, 2020
c03f6a9
Add comments and use agg config
Jul 30, 2020
9068775
Added agg configs
Jul 30, 2020
0f546af
Adding getEsQuery to query service (??)
Jul 30, 2020
2614b3d
Merge branch 'master' of github.com:elastic/kibana into search/server…
Aug 2, 2020
93e1c55
Add server side example
Aug 2, 2020
b100cfe
docs
Aug 2, 2020
63e934a
Merge branch 'master' into search/server-strategy-example
elasticmachine Aug 3, 2020
f528d57
caps
Aug 3, 2020
0b1f36a
Merge branch 'search/server-strategy-example' of github.com:lizozom/k…
Aug 3, 2020
c451122
list plugin in examples page
Aug 3, 2020
cf06006
Merge branch 'master' of github.com:elastic/kibana into search/server…
Aug 4, 2020
48aead1
fix typo
Aug 4, 2020
e86823a
Merge branch 'master' of github.com:elastic/kibana into search/server…
Aug 4, 2020
f90a78d
Update examples/search_examples/public/application.tsx
lizozom Aug 5, 2020
d5f1976
Update examples/search_examples/public/application.tsx
lizozom Aug 5, 2020
b118ea0
Update examples/search_examples/public/components/app.tsx
lizozom Aug 5, 2020
828ab62
Update examples/search_examples/public/components/app.tsx
lizozom Aug 5, 2020
b54f734
Update examples/search_examples/public/components/app.tsx
lizozom Aug 5, 2020
5459bca
Merge branch 'master' into search/server-strategy-example
elasticmachine Aug 6, 2020
741d8b3
Merge branch 'master' into search/server-strategy-example
elasticmachine Aug 6, 2020
0a67c4f
eslint
Aug 10, 2020
1960c84
Merge branch 'master' of github.com:elastic/kibana into search/server…
Aug 10, 2020
9aebaae
Merge branch 'search/server-strategy-example' of github.com:lizozom/k…
Aug 10, 2020
dff19c8
Merge branch 'master' into search/server-strategy-example
elasticmachine Aug 11, 2020
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IEsSearchResponse](./kibana-plugin-plugins-data-public.iessearchresponse.md) &gt; [isPartial](./kibana-plugin-plugins-data-public.iessearchresponse.ispartial.md)

## IEsSearchResponse.isPartial property

Indicates whether the results returned are complete or partial

<b>Signature:</b>

```typescript
isPartial?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IEsSearchResponse](./kibana-plugin-plugins-data-public.iessearchresponse.md) &gt; [isRunning](./kibana-plugin-plugins-data-public.iessearchresponse.isrunning.md)

## IEsSearchResponse.isRunning property

Indicates whether async search is still in flight

<b>Signature:</b>

```typescript
isRunning?: boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ export interface IEsSearchResponse extends IKibanaSearchResponse

| Property | Type | Description |
| --- | --- | --- |
| [isPartial](./kibana-plugin-plugins-data-public.iessearchresponse.ispartial.md) | <code>boolean</code> | Indicates whether the results returned are complete or partial |
| [isRunning](./kibana-plugin-plugins-data-public.iessearchresponse.isrunning.md) | <code>boolean</code> | Indicates whether async search is still in flight |
| [rawResponse](./kibana-plugin-plugins-data-public.iessearchresponse.rawresponse.md) | <code>SearchResponse&lt;any&gt;</code> | |

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

```typescript
export declare type ISearchGeneric = (request: IEsSearchRequest, options?: IStrategyOptions) => Observable<IEsSearchResponse>;
export declare type ISearchGeneric = (request: IEsSearchRequest, options?: ISearchOptions) => Observable<IEsSearchResponse>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export interface ISearchOptions
| Property | Type | Description |
| --- | --- | --- |
| [signal](./kibana-plugin-plugins-data-public.isearchoptions.signal.md) | <code>AbortSignal</code> | |
| [strategy](./kibana-plugin-plugins-data-public.isearchoptions.strategy.md) | <code>string</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-public](./kibana-plugin-plugins-data-public.md) &gt; [ISearchOptions](./kibana-plugin-plugins-data-public.isearchoptions.md) &gt; [strategy](./kibana-plugin-plugins-data-public.isearchoptions.strategy.md)

## ISearchOptions.strategy property

<b>Signature:</b>

```typescript
strategy?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export declare class SearchInterceptor

| Method | Modifiers | Description |
| --- | --- | --- |
| [runSearch(request, signal)](./kibana-plugin-plugins-data-public.searchinterceptor.runsearch.md) | | |
| [runSearch(request, signal, strategy)](./kibana-plugin-plugins-data-public.searchinterceptor.runsearch.md) | | |
| [search(request, options)](./kibana-plugin-plugins-data-public.searchinterceptor.search.md) | | Searches using the given <code>search</code> method. Overrides the <code>AbortSignal</code> with one that will abort either when <code>cancelPending</code> is called, when the request times out, or when the original <code>AbortSignal</code> is aborted. Updates the <code>pendingCount</code> when the request is started/finalized. |
| [setupTimers(options)](./kibana-plugin-plugins-data-public.searchinterceptor.setuptimers.md) | | |

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

```typescript
protected runSearch(request: IEsSearchRequest, signal: AbortSignal): Observable<IEsSearchResponse>;
protected runSearch(request: IEsSearchRequest, signal: AbortSignal, strategy?: string): Observable<IEsSearchResponse>;
```

## Parameters
Expand All @@ -16,6 +16,7 @@ protected runSearch(request: IEsSearchRequest, signal: AbortSignal): Observable<
| --- | --- | --- |
| request | <code>IEsSearchRequest</code> | |
| signal | <code>AbortSignal</code> | |
| strategy | <code>string</code> | |

<b>Returns:</b>

Expand Down
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; [IEsSearchRequest](./kibana-plugin-plugins-data-server.iessearchrequest.md) &gt; [indexType](./kibana-plugin-plugins-data-server.iessearchrequest.indextype.md)

## IEsSearchRequest.indexType property

<b>Signature:</b>

```typescript
indexType?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- 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; [IEsSearchRequest](./kibana-plugin-plugins-data-server.iessearchrequest.md)

## IEsSearchRequest interface

<b>Signature:</b>

```typescript
export interface IEsSearchRequest extends IKibanaSearchRequest
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [indexType](./kibana-plugin-plugins-data-server.iessearchrequest.indextype.md) | <code>string</code> | |
| [params](./kibana-plugin-plugins-data-server.iessearchrequest.params.md) | <code>ISearchRequestParams</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; [IEsSearchRequest](./kibana-plugin-plugins-data-server.iessearchrequest.md) &gt; [params](./kibana-plugin-plugins-data-server.iessearchrequest.params.md)

## IEsSearchRequest.params property

<b>Signature:</b>

```typescript
params?: ISearchRequestParams;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- 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; [IEsSearchResponse](./kibana-plugin-plugins-data-server.iessearchresponse.md) &gt; [isPartial](./kibana-plugin-plugins-data-server.iessearchresponse.ispartial.md)

## IEsSearchResponse.isPartial property

Indicates whether the results returned are complete or partial

<b>Signature:</b>

```typescript
isPartial?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- 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; [IEsSearchResponse](./kibana-plugin-plugins-data-server.iessearchresponse.md) &gt; [isRunning](./kibana-plugin-plugins-data-server.iessearchresponse.isrunning.md)

## IEsSearchResponse.isRunning property

Indicates whether async search is still in flight

<b>Signature:</b>

```typescript
isRunning?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- 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; [IEsSearchResponse](./kibana-plugin-plugins-data-server.iessearchresponse.md)

## IEsSearchResponse interface

<b>Signature:</b>

```typescript
export interface IEsSearchResponse extends IKibanaSearchResponse
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [isPartial](./kibana-plugin-plugins-data-server.iessearchresponse.ispartial.md) | <code>boolean</code> | Indicates whether the results returned are complete or partial |
| [isRunning](./kibana-plugin-plugins-data-server.iessearchresponse.isrunning.md) | <code>boolean</code> | Indicates whether async search is still in flight |
| [rawResponse](./kibana-plugin-plugins-data-server.iessearchresponse.rawresponse.md) | <code>SearchResponse&lt;any&gt;</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; [IEsSearchResponse](./kibana-plugin-plugins-data-server.iessearchresponse.md) &gt; [rawResponse](./kibana-plugin-plugins-data-server.iessearchresponse.rawresponse.md)

## IEsSearchResponse.rawResponse property

<b>Signature:</b>

```typescript
rawResponse: SearchResponse<any>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
| [EsQueryConfig](./kibana-plugin-plugins-data-server.esqueryconfig.md) | |
| [FieldFormatConfig](./kibana-plugin-plugins-data-server.fieldformatconfig.md) | |
| [Filter](./kibana-plugin-plugins-data-server.filter.md) | |
| [IEsSearchRequest](./kibana-plugin-plugins-data-server.iessearchrequest.md) | |
| [IEsSearchResponse](./kibana-plugin-plugins-data-server.iessearchresponse.md) | |
| [IFieldSubType](./kibana-plugin-plugins-data-server.ifieldsubtype.md) | |
| [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) | |
| [IIndexPattern](./kibana-plugin-plugins-data-server.iindexpattern.md) | |
Expand Down
9 changes: 9 additions & 0 deletions examples/search_examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# search_examples

> An awesome Kibana plugin

---

## Development

See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment.
32 changes: 32 additions & 0 deletions examples/search_examples/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { IEsSearchResponse, IEsSearchRequest } from '../../../src/plugins/data/common';

export const PLUGIN_ID = 'searchExamples';
export const PLUGIN_NAME = 'Search Examples';

export interface IMyStrategyRequest extends IEsSearchRequest {
get_cool: boolean;
}
export interface IMyStrategyResponse extends IEsSearchResponse {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some thoughts: I wonder if it will be more common for custom strategies to extend IKibanaSearchResponse rather than IEsSearchResponse since they will likely be doing some sort of data manipulation and not sending the raw response back.

cool: string;
}

export const SERVER_SEARCH_ROUTE_PATH = '/api/examples/search';
9 changes: 9 additions & 0 deletions examples/search_examples/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "searchExamples",
"version": "8.0.0",
"server": true,
"ui": true,
"requiredPlugins": ["navigation", "data", "developerExamples"],
"optionalPlugins": [],
"requiredBundles": []
}
44 changes: 44 additions & 0 deletions examples/search_examples/public/application.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';
import ReactDOM from 'react-dom';
import { AppMountParameters, CoreStart } from '../../../src/core/public';
import { AppPluginStartDependencies } from './types';
import { SearchExamplesApp } from './components/app';

export const renderApp = (
{ notifications, savedObjects, http }: CoreStart,
{ navigation, data }: AppPluginStartDependencies,
{ appBasePath, element }: AppMountParameters
) => {
ReactDOM.render(
<SearchExamplesApp
basename={appBasePath}
notifications={notifications}
savedObjectsClient={savedObjects.client}
navigation={navigation}
data={data}
http={http}
/>,
element
);

return () => ReactDOM.unmountComponentAtNode(element);
};
Loading