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

Add dataset_types to package info #511

Closed
wants to merge 4 commits into from

Conversation

ruflin
Copy link
Member

@ruflin ruflin commented Jun 15, 2020

To be updated

@ruflin ruflin self-assigned this Jun 15, 2020
@elasticmachine
Copy link

elasticmachine commented Jun 15, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #511 updated]

  • Start Time: 2020-06-22T08:22:06.265+0000

  • Duration: 11 min 39 sec

Test stats 🧪

Test Results
Failed 0
Passed 109
Skipped 0
Total 109

@ruflin
Copy link
Member Author

ruflin commented Jun 16, 2020

As this does not remove / change the /categories endpoint yet, this can be merged and the change in Kibana can follow. Issue filed here: elastic/kibana#69252

docs/api/package.json Outdated Show resolved Hide resolved
docs/api/search-datasetType-logs.json Outdated Show resolved Hide resolved
docs/api/search-datasetType-logs.json Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@@ -48,6 +49,12 @@ func searchHandler(packagesBasePath string, cacheTime time.Duration) func(w http
}
}

if v := query.Get("dataset.type"); v != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: dataset_type ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is by design. I want to stay as close as possible to the actual fields used in the events. So the query is really dataset.type=logs like it is inside Elasticsearch.

types.go Outdated

data, err := getTypesOutput(types)
if err != nil {
notFoundError(w, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can get here a marshaling error. It would be great if the app logs this one.

util/package.go Outdated
@@ -50,6 +50,8 @@ type Package struct {
Datasources []Datasource `config:"datasources,omitempty" json:"datasources,omitempty" yaml:"datasources,omitempty"`
Download string `json:"download" yaml:"download,omitempty"`
Path string `json:"path" yaml:"path,omitempty"`
// This is in purpose `dataset.types` with an "s" as it is a summary of the existing dataset types
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: on purpose:

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

util/package.go Outdated
@@ -50,6 +50,8 @@ type Package struct {
Datasources []Datasource `config:"datasources,omitempty" json:"datasources,omitempty" yaml:"datasources,omitempty"`
Download string `json:"download" yaml:"download,omitempty"`
Path string `json:"path" yaml:"path,omitempty"`
// This is in purpose `dataset.types` with an "s" as it is a summary of the existing dataset types
DatasetTypes []string `json:"dataset.types" yaml:"dataset.types,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

should both ones have the omitempty annotation?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, and I realised that we don't need the yaml part as it never shows up in yaml.

util/package.go Outdated Show resolved Hide resolved
util/package.go Show resolved Hide resolved
The type API endpoint exposes the number of packages with a dataset of a certain type exists. Today this is what is exposed by the category endpoint but this will be repurposed. The value of the type is based on the dataset.type field, indirectly the type definition inside the dataset manifest.

It is expected that Kibana switches over to using this endpoint and then the category endpoint can be refactored. What is currently exposed under category is not really categories.
Copy link
Member Author

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

I removed the /types endpoint from this PR as it turned out we don't need it for the next release. But we potentially need the types info of the dataset types in a package on the search endpoint. Will update the PR description and add more changes for it.

docs/api/package.json Outdated Show resolved Hide resolved
docs/api/search-datasetType-logs.json Outdated Show resolved Hide resolved
docs/api/search-datasetType-logs.json Outdated Show resolved Hide resolved
search.go Outdated Show resolved Hide resolved
search.go Outdated Show resolved Hide resolved
util/package.go Outdated
@@ -50,6 +50,8 @@ type Package struct {
Datasources []Datasource `config:"datasources,omitempty" json:"datasources,omitempty" yaml:"datasources,omitempty"`
Download string `json:"download" yaml:"download,omitempty"`
Path string `json:"path" yaml:"path,omitempty"`
// This is in purpose `dataset.types` with an "s" as it is a summary of the existing dataset types
Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

util/package.go Outdated
@@ -50,6 +50,8 @@ type Package struct {
Datasources []Datasource `config:"datasources,omitempty" json:"datasources,omitempty" yaml:"datasources,omitempty"`
Download string `json:"download" yaml:"download,omitempty"`
Path string `json:"path" yaml:"path,omitempty"`
// This is in purpose `dataset.types` with an "s" as it is a summary of the existing dataset types
DatasetTypes []string `json:"dataset.types" yaml:"dataset.types,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

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

yes, and I realised that we don't need the yaml part as it never shows up in yaml.

util/package.go Outdated Show resolved Hide resolved
util/package.go Show resolved Hide resolved
@ruflin
Copy link
Member Author

ruflin commented Jun 22, 2020

Waiting for #529 to get in to continue work on this PR.

I converted above dataset.types to dataset: { types but I'm torn if this is the right call. The reason I converted it to an object is to align with dataset.* object but at the same time inside this object there is not types (plural) and it kind of implies a dataset could have more than one type (it can't). So I'm getting back to the proposal from @mtojek to use dataset_types. Will adjust it.

@ruflin ruflin changed the title Add /types API endpoint Add dataset_types to package info Jun 22, 2020
@ruflin
Copy link
Member Author

ruflin commented Jul 2, 2020

I'm closing this for now as it turned out we will not need it yet for the next release.

@ruflin ruflin closed this Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants