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

[Question] Independent facet labels and values #580

Open
julianklotz opened this issue Aug 3, 2021 · 9 comments
Open

[Question] Independent facet labels and values #580

julianklotz opened this issue Aug 3, 2021 · 9 comments

Comments

@julianklotz
Copy link

julianklotz commented Aug 3, 2021

Dear community,

here’s an interesting case I have. I’d like to use MultiCheckBox facets for filtering.
My facets aren’t string-only, but objects with ID and name field, because we do have some ambiguous labels:

// pseudo code – structure of facets
let facets = {
  seasons: [{
    id: 123,
    name: "Season 1981/82"
  }, {
    id: 123,
    name: "Season 1982/83"
  }
}

I’d like to use the object’s ID for filtering, but use its name as label for MultiCheckBox facets.
From what I’ve seen, I think that Search UI facets (except for range fields) only works with string-only (or other primitives) facets.

What is the intended way to go in such a case?

@julianklotz julianklotz changed the title Independent facet labels and values [Question] Independent facet labels and values Aug 3, 2021
@botelastic
Copy link

botelastic bot commented Oct 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Is this issue still important to you? If so, please leave a comment and let us know. As always, thank you for your contributions.

@botelastic botelastic bot added the wontfix This will not be worked on label Oct 2, 2021
@julianklotz
Copy link
Author

Any ideas here? Still haven’t found what I’m looking for 🎶

@botelastic botelastic bot removed the wontfix This will not be worked on label Oct 4, 2021
@JasonStoltz
Copy link
Member

Sorry for the delay. Are you using this with App Search? Or Elasticsearch? Or some other backend?

I'm having trouble wrapping my head around your problem.

I'm going to close this issue for now because I'm pretty sure the answer is "no, it's not possible", but feel free to add more color to the conversation, I might be missing something.

@julianklotz
Copy link
Author

Thanks @JasonStoltz – I guess you’re right. I was looking for a way to use objects (with label and value properties) for faceting.

My use case is this:

  • My website has a search page that is backed by plain ElasticSearch (without app & site search connectors)
  • Let’s say you can use the search page (build with Search UI) to filter photos by their period of creation, using aggregations by seasons (it’s about performing arts :-))
  • The website is multi-language, so my filter value is something like “Season 1981/82” (EN), “Saison 1981/82” (FR), …
  • I’d like to deep-link the search results page from various other places, e.g. “Search all photos for season 1981/1982“, pointing to /search/?season=123&type=456. The important thing here is using season and type IDs instead of (translatable) strings, so I don’t need to keep track of various translations, but can use IDs for deep linking.

What I wanted to do: Find a way to set season ID 123 as filter value internally, but display „Season 1981/82“ (or any other label from aggregations).

Here’s my actual solution: Before rendering the search results page, I parse the params (?season=123&type=456) and run an aggregation query. I use the buckets to map the IDs to the labels that ES uses.

@JasonStoltz
Copy link
Member

That's a really good point. Being able to handle this scenario would be really valuable, especially given i18n requirements.

I actually think it'd be easy enough to add support for this use case to search-ui. I'm going to reopen this and handle it as a feature request.

Good call, thanks for adding your explanation!

@botelastic
Copy link

botelastic bot commented Dec 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Is this issue still important to you? If so, please leave a comment and let us know. As always, thank you for your contributions.

@botelastic botelastic bot added the wontfix This will not be worked on label Dec 11, 2021
@JasonStoltz JasonStoltz added pinned and removed wontfix This will not be worked on labels Dec 13, 2021
@marcvangend
Copy link

Following. This is a rather common requirement for us.

@JasonStoltz
Copy link
Member

Got it. For what it's worth, in the meantime, you should be able to create a "Custom" view for this.

The process describing how to do this can be found in the Advanced guide.

So it shouldn't be a total dead-end right now, but we could definitely make it easier in the future.

@marcvangend
Copy link

Thanks Jason. In fact we did create a custom view, but like you say, it could be much easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants