Algolia’s sort of numeric facet by alphabetical order is wrong

  • memphdutch
    Participant
    # 2 years, 2 months ago

    Hi,

    I downloaded WP Solr yesterday, and it has been a great help. Thank you so much.

    I am using it with Algolia. I have a site that has facets on the sidebar that let the user find parts of the Bible. The problem I am running into is the sorting of the attributes. In the link below, I want to:

    1) put the books in biblical order (Genesis, Exodus, Leviticus).

    2) put the chapters in numerical order. Right now it sorts 1, 10, 119, 13, 145.

    Snapshot: https://www.dropbox.com/s/2y3clmh9uttlvme/Screen%20Shot%202020-04-02%20at%208.43.52%20AM.png?dl=0

    I know Algolia restricts to ordering by alphabetical or by count. In their documentation for instantsearch.js they indicate that there is a way to specify order, but that doesn’t necessarily apply here. https://discourse.algolia.com/t/sorting-in-facets/7709

    What are my options?

    wpsolr
    Keymaster
    # 2 years, 2 months ago

    Is the alpha sort is working for numeric facet values only?

    memphdutch
    Participant
    # 2 years, 2 months ago

    In the screenshot, book is sorted by frequency.

    memphdutch
    Participant
    # 2 years, 2 months ago

    I was incorrect – “book” was sorted alphabetical correctly.

    https://www.dropbox.com/s/ljr09kyg9q92aef/Screen%20Shot%202020-04-02%20at%209.39.00%20AM.png?dl=0

    wpsolr
    Keymaster
    # 2 years, 2 months ago

    I could replicate the problem locally. The solution suggested seems to be making the sort in WPSOLR.

    memphdutch
    Participant
    # 2 years, 2 months ago

    How would I make the sort in WPSOLR?

    wpsolr
    Keymaster
    # 2 years, 2 months ago

    I’m building a small fix in WPSOLR.

    memphdutch
    Participant
    # 2 years, 2 months ago

    Thank you.

    wpsolr
    Keymaster
    # 2 years, 2 months ago

    Here is the fix:
    https://www.dropbox.com/s/wl8ugtak0uvud3p/wpsolr-pro-fix-algolia-numeric-alpha-sort.zip?dl=0

    1) Please deactivate the WPSOLR plugin, and remove it. Upload the new version with the fix, and activate it.

    2) Please change to type “Integer” for your “Chapter” field in your screen 2.2 and reindex everything, if the type was a string.

    The fix is detecting fields indexed with a numeric type in screen 2.2 (“Integer” for “Chapter”) with a facet with alphabetical sort. It then reorders the facet content correctly.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.