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 schema mapping and provide examples of different names #404

Closed
tacman opened this issue Jun 27, 2024 · 2 comments
Closed

document schema mapping and provide examples of different names #404

tacman opened this issue Jun 27, 2024 · 2 comments

Comments

@tacman
Copy link

tacman commented Jun 27, 2024

$index = new Index('blog', [
    'title' => new Field\TextField('title', sortable: true),
    'tags' => new Field\TextField('tags', multiple: true, filterable: true),
    'internalNote' => new Field\TextField('internalNote', searchable: false),
]);

In the above and all the examples I can find on the website, the key and the field name are the same. I assume there's map that ways "when you see this key in the document being indexed, store it as a key of this type".

But I'm not sure which is which.

$index = new Index('imdb', [
    'movie_name' => new Field\TextField('title', sortable: true),
    'Genres' => new Field\TextField('genre', multiple: true, filterable: true),
    'Directory Notes' => new Field\TextField('internalNote', searchable: false),
]);

As some of my data comes from CSV files with first columns that are more labels, I'm curious about how the mapping it done.

@alexander-schranz
Copy link
Member

alexander-schranz commented Jul 9, 2024

@tacman currently the key need to match the name. There is currently no support for aliases / different mapped field names. I'm not yet sure if I planned to implement such thing or not. As at current case it just unnecessary rethinking which I think make things harder as needed

So just keep the name same as you want to access it in your documents, you should not care about how it is stored:

$index = new Index('imdb', [
    'title' => new Field\TextField('title', sortable: true),
    'genres' => new Field\TextField('genres', multiple: true, filterable: true),
    'directoryNote' => new Field\TextField('directoryNote', searchable: false),
]);

@alexander-schranz
Copy link
Member

A validation for key === field.name was added in #427. If this get change we will tackle #200, if you want subscribe that issue. Thx for the feedback.

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

2 participants