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 wildcard type support to go code generator #1050

Merged
merged 3 commits into from
Oct 27, 2020
Merged
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion scripts/cmd/gocodegen/gocodegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func goDataType(fieldName, elasticsearchDataType string) string {
}

switch elasticsearchDataType {
case "keyword", "text", "ip", "geo_point":
case "keyword", "wildcard", "text", "ip", "geo_point":
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 we should take the opportunity to also add version as well, here. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea!

Does using string work here for the version data type or is there a more appropriate type to use?

cc @andrewkroh

Copy link
Member Author

Choose a reason for hiding this comment

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

And perhaps constant_keyword could be another addition here.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, string seems like the best option for version. Another option would be a struct that has parameters that match up with the version data type (but I've never seen the version data type in ES so I have no idea what it looks like).

Copy link
Contributor

Choose a reason for hiding this comment

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

version is another type in the keyword family. So you can safely cram all manners of weird/incorrect version strings in it. But well-formatted ones will be queryable in new interesting ways.

So I think the simple answer is to have it equivalent to a Go string.

I don't object to supporting constant_keyword here. But let me open a door for a moment🚪

constant_keyword will be tricky to add to "main ECS", because using it means any index not using it correctly will have ingestion screech to a halt when sending a second value for the field.

I'm thinking it will have to be some sort of explicit opt-in, for folks who know they are adopting that specific strategy to splitting indices. Its usage will work much better with composable templates.

But we can close that door 🚪 and add constant_keyword as well 😂

Copy link
Member Author

Choose a reason for hiding this comment

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

Both version and constant_keyword have been added.

We've had some recent discussions around version being a keyword specialization type instead of a member of the keyword family. If that changes feelings around including it here (for now), I'm ok to remove.

Copy link
Contributor

@webmat webmat Oct 27, 2020

Choose a reason for hiding this comment

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

Let's leave it in for now. I'm not sure if the incompatibility we saw in the field caps API call is an oversight or if it's here to stay. If it's here to stay, it's likely because the query possibilities are significantly greater with version (pun intended).

But the structure of the data itself is best captured as a string in the various programming languages.

return "string"
case "long":
return "int64"
Expand Down