Skip to content

Commit

Permalink
[Search] Server strategy example (elastic#71679)
Browse files Browse the repository at this point in the history
* Server strategy example

* Add tsconfig
Renamed is_partial to isPartial
Added isPartial and isRunning to OSS response type

* Docs + remove unused sample code

* Fix test naming of arguments

* ts

* ts fix

* Add filters and query input selector

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

* Use new service

* exapmle plugin ts

* unsubscribe + use timefilter

* typo

* docs

* Add comments and use agg config

* Added agg configs
Added field selector
Added a custom input param

* Adding getEsQuery to query service (??)

* Add server side example

* docs

* caps

* list plugin in examples page

* fix typo

* Update examples/search_examples/public/application.tsx

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

* Update examples/search_examples/public/application.tsx

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

* Update examples/search_examples/public/components/app.tsx

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

* eslint

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 11, 2020
1 parent d786442 commit 506e953
Show file tree
Hide file tree
Showing 49 changed files with 1,161 additions and 106 deletions.
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 {
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

0 comments on commit 506e953

Please sign in to comment.