-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 plugin README #78750
Merged
Merged
Data plugin README #78750
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e526139
data readme
7e76977
Delete old readme (other folders don't have a README of their own.
018964b
Merge branch 'master' into docs/search-service-readme
elasticmachine e3a9b47
generate asciidoc
cdfc28f
Merge branch 'docs/search-service-readme' of github.com:lizozom/kiban…
0d6eef0
Update src/plugins/data/README.md
lizozom 0e5e299
Update src/plugins/data/README.md
lizozom 79e64b7
Update src/plugins/data/README.md
lizozom 6c23345
Update src/plugins/data/README.md
lizozom f872f4e
Update src/plugins/data/README.md
lizozom 9c67a21
Update src/plugins/data/README.md
lizozom f5bbdb6
Update src/plugins/data/README.md
lizozom ab3a3a1
Update src/plugins/data/README.md
lizozom 51dbf51
Update src/plugins/data/README.md
lizozom abcf85d
Update src/plugins/data/README.md
lizozom 8cd1954
Update src/plugins/data/README.md
lizozom 07d22df
Update src/plugins/data/README.md
lizozom e69566c
Update README.md
lizozom b5e17fe
Update plugin-list.asciidoc
lizozom e79e987
Merge branch 'master' of github.com:elastic/kibana into docs/search-s…
729faa2
Merge branch 'docs/search-service-readme' of github.com:lizozom/kiban…
129e229
gen plugin list
51d4c58
Update src/plugins/data/README.md
lizozom fd2f505
Update src/plugins/data/README.md
lizozom 8481a61
Update src/plugins/data/README.md
lizozom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,137 @@ | ||
# data | ||
|
||
`data` plugin provides common data access services. | ||
The data plugin provides common data access services, such as `search` and `query`, for solutions and application developers. | ||
|
||
- `expressions` — run pipeline functions and render results. | ||
- `filter` | ||
- `index_patterns` | ||
- `query` | ||
- `search`: Elasticsearch API service and strategies | ||
## Autocomplete | ||
|
||
The autocomplete service provides suggestions for field names and values. | ||
|
||
It is wired into the `TopNavMenu` component, but can be used independently. | ||
|
||
### Fetch Query Suggestions | ||
|
||
The `getQuerySuggestions` function helps to construct a query. | ||
KQL suggestion functions are registered in X-Pack, so this API does not return results in OSS. | ||
|
||
```.ts | ||
|
||
// `inputValue` is the user input | ||
const querySuggestions = await autocomplete.getQuerySuggestions({ | ||
language: 'kuery', | ||
indexPatterns: [indexPattern], | ||
query: inputValue, | ||
}); | ||
|
||
``` | ||
|
||
### Fetch Value Suggestions | ||
|
||
The `getValueSuggestions` function returns suggestions for field values. | ||
This is helpful when you want to provide a user with options, for example when constructing a filter. | ||
|
||
```.ts | ||
|
||
// `inputValue` is the user input | ||
const valueSuggestions = await autocomplete.getValueSuggestions({ | ||
indexPattern, | ||
field, | ||
query: inputValue, | ||
}); | ||
|
||
``` | ||
|
||
## Field Formats | ||
|
||
Coming soon. | ||
|
||
## Index Patterns | ||
|
||
Coming soon. | ||
|
||
## Query | ||
|
||
The query service is responsible for managing the configuration of a search query (`QueryState`): filters, time range, query string, and settings such as the auto refresh behavior and saved queries. | ||
|
||
It contains sub-services for each of those configurations: | ||
- `data.query.filterManager` - Manages the `filters` component of a `QueryState`. The global filter state (filters that are persisted between applications) are owned by this service. | ||
- `data.query.timefilter` - Responsible for the time range filter and the auto refresh behavior settings. | ||
- `data.query.queryString` - Responsible for the query string and query language settings. | ||
- `data.query.savedQueries` - Responsible for persisting a `QueryState` into a `SavedObject`, so it can be restored and used by other applications. | ||
|
||
Any changes to the `QueryState` are published on the `data.query.state$`, which is useful when wanting to persist global state or run a search upon data changes. | ||
|
||
A simple use case is: | ||
|
||
```.ts | ||
function searchOnChange(indexPattern: IndexPattern, aggConfigs: AggConfigs) { | ||
data.query.state$.subscribe(() => { | ||
|
||
// Constuct the query portion of the search request | ||
const query = data.query.getEsQuery(indexPattern); | ||
|
||
// Construct a request | ||
const request = { | ||
params: { | ||
index: indexPattern.title, | ||
body: { | ||
aggs: aggConfigs.toDsl(), | ||
query, | ||
}, | ||
}, | ||
}; | ||
|
||
// Search with the `data.query` config | ||
const search$ = data.search.search(request); | ||
|
||
... | ||
}); | ||
} | ||
|
||
``` | ||
|
||
## Search | ||
|
||
Provides access to Elasticsearch using the high-level `SearchSource` API or low-level `Search Strategies`. | ||
|
||
### SearchSource | ||
|
||
The `SearchSource` API is a convenient way to construct and run an Elasticsearch search query. | ||
|
||
```.tsx | ||
|
||
const searchSource = await data.search.searchSource.create(); | ||
const searchResponse = await searchSource | ||
.setParent(undefined) | ||
.setField('index', indexPattern) | ||
.setField('filter', filters) | ||
.fetch(); | ||
|
||
``` | ||
|
||
### Low-level search | ||
|
||
#### Default Search Strategy | ||
|
||
One benefit of using the low-level search API, is partial response support in X-Pack, allowing for a better and more responsive user experience. | ||
In OSS only the final result is returned. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Add a note about how we also apply defaults from advanced settings/config.yml so that the consumer doesn't need to worry about these |
||
|
||
```.ts | ||
import { isCompleteResponse } from '../plugins/data/public'; | ||
|
||
const search$ = data.search.search(request) | ||
.subscribe({ | ||
next: (response) => { | ||
if (isCompleteResponse(response)) { | ||
// Final result | ||
search$.unsubscribe(); | ||
} else { | ||
// Partial result - you can update the UI, but data is still loading | ||
} | ||
}, | ||
error: (e: Error) => { | ||
// Show customized toast notifications. | ||
// You may choose to handle errors differently if you prefer. | ||
data.search.showError(e); | ||
}, | ||
}); | ||
``` |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Add a short explanation of how search source inherits from the root search source (global time filter) by default and explain that this overrides that default behavior