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

[search-documents] Nest user-defined fields into a document property #9537

Closed
xirzec opened this issue Jun 15, 2020 · 2 comments
Closed

[search-documents] Nest user-defined fields into a document property #9537

xirzec opened this issue Jun 15, 2020 · 2 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Search
Milestone

Comments

@xirzec
Copy link
Member

xirzec commented Jun 15, 2020

To prevent accidentally shadowing user-defined fields with server metadata, we should modify the following interfaces:

// existing interfaces
export type SearchResult<T> = {
    readonly score: number;
    readonly highlights?: {
        [propertyName: string]: string[];
    };
} & T;

export type SuggestResult<T> = {
    readonly text: string;
} & T;

to instead nest the user defined fields:

// desired interfaces
export type SearchResult<T> = {
    readonly score: number;
    readonly highlights?: {
        [propertyName: string]: string[];
    };
    document: T;
}

export type SuggestResult<T> = {
    readonly text: string;
    document: T;
};

In order to accomplish this in code, we will likely have to create a swagger transform to rewrite the server-metadata to map to names that can't conflict (e.g. underscore prefix, so @search.score becomes _score instead of score) and then writing a conversion function to massage the generated interface into the above public shape.

@xirzec xirzec added Client This issue points to a problem in the data-plane of the library. Search labels Jun 15, 2020
@xirzec xirzec added this to the [2020] July milestone Jun 15, 2020
@sarangan12
Copy link
Member

#9655

@sarangan12
Copy link
Member

Code complete

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Search
Projects
None yet
Development

No branches or pull requests

2 participants