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

Support imported fields in document/v1 API #33080

Open
zygisx opened this issue Jan 6, 2025 · 1 comment
Open

Support imported fields in document/v1 API #33080

zygisx opened this issue Jan 6, 2025 · 1 comment
Assignees
Milestone

Comments

@zygisx
Copy link

zygisx commented Jan 6, 2025

Is your feature request related to a problem? Please describe.
This is missing feature, not a problem.
When using parent/child documents and importing fields from parent, there is no way to retrieve imported fields using document/v1 api.

Describe the solution you'd like
document/v1 API has fieldSet query param documented. Though currently passing imported field to this param does not result in error.

Example:

search advertiser {
    document advertiser {
        field company_name type string {
            indexing: attribute | summary
        }
    }
}

search campaign {
    document campaign {
        field advertiser_ref type reference<advertiser> {
            indexing: attribute
        }
        field name type string {
            indexing: attribute | summary
        }
    }
    import field advertiser_ref.company_name as campaign_company_name {}
}

curl --location 'http://localhost:8080/document/v1/campaing/campaign/docid/123456?fieldSet=campaign_company_name'

Returns:

ReturnCode(ILLEGAL_PARAMETERS, Field campaign_company_name in fieldset campaing:campaign_company_name not found in document) 

Describe alternatives you've considered
Alternative would be to use search API with document summary, which includes imported fields. Though this is not that convenient if we only need to retrieve document by id.

Additional context
Initial request in slack

@geirst geirst added this to the later milestone Jan 15, 2025
@vekterli
Copy link
Member

This is a very understandable feature request, since it's already possible to use imported fields as part of the document selection visiting predicate via Document V1.

Unfortunately, it's not a trivial change; Document V1 (and the lower level Document API it uses) operates on—and returns—document instances that conform to the document type schema, but imported fields are declared outside of the document type. In other words, there is no concrete field in the document instance that can be populated from an imported field value. The document selection and query evaluation pipelines in the backend have explicit handling of imported fields to create the illusion that they can be used as if they were part of the document type, but this abstraction does not exist on a higher level.

Including imported fields in documents would also break the assumption that you can directly pipe the output of visiting into feeding, as such fields cannot be written to.

We would likely need some way of representing "meta-level" fields in the output, but this does not exist today. Input for Document V2 work...

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

3 participants