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

Document source with dynamic fields #65

Open
anti-social opened this issue Apr 26, 2022 · 0 comments
Open

Document source with dynamic fields #65

anti-social opened this issue Apr 26, 2022 · 0 comments

Comments

@anti-social
Copy link
Owner

anti-social commented Apr 26, 2022

Consider following document:

object UserDoc : Document() {
    override val dynamicTemplates : DynamicTemplates() {
        val ids by template(
            mapping = long(index = false).subFields(::IdSubFields),
            match = "*_id",
        )
        val strings by template(
            mapping = Mapping(
                docValues = false,
            ),
            matchMappingType = MatchMappingType.STRING,
        )
    }
}

We want *_id fields to be mapped in document source class.

class UserDocSource : DocSource() {
    val ids by UserDoc.dynamicTemplates.ids
    val strings by UserDoc.dynamicTemplates.strings
}

So then we could write:

val companyId: Long = user.ids["company_id"]
val comment: String = user.strings["comment"]
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

No branches or pull requests

1 participant