Ranking by a nested attribute

Hello,

I am trying to rank my results by a nested attribute, however, the Algolia dashboard does not present it as an option (and typing it in manually does not do anything).

Example data set:

title: “Software Engineer”
organization: {
    name: “ABC Enterprises”
    date_created: 1565418289
    id: 1
}

I would like to rank my results say by organization.id or organization.name, but none of these are options in Algolia. It is happy for me to sort by title, but not by organization.name.

The only solution I can think of is to to make my dataset as follows (say if I was ranking by name):

title: “Software Engineer”
organization: {
    name: “ABC Enterprises”
    date_created: 1565418289
    id: 1
}
organization_name: "ABC Enterprises"

I don’t like duplication though, so seeing if there is a nicer solution.

Thanks,
Jack

Hi Jack,

if I understand correctly you want to use nested attributes as a sort-by attribute or in the custom ranking.

You indeed do not need to duplicate the data and can achieve this by using the “dot” notation e.g. to sort-by organization id, you could add organization.id as a sort-by attribute.

Our documentation doesn’t make this explicit everywhere however, it is mentionned for

Hope that helps, please let us know if you have other question or feedback.