Currently, we don't allow sorting on multi-valued or fulltext fields at all, preventing it right in the query class, and in search modules like the Views integration. This makes sense insofar that sorting on multi-valued fields a) makes no real sense conceptually, at least in most cases, and b) is not supported by most backends (probably because of a)). Also, fulltext fields consist of tokens, so can also be seen as multi-valued – though sorting on things like node titles does make a lot of sense.

So, for the D8 version we should probably re-evaluate this regulation to see how much sense it makes. So, which of the following variants would you prefer for the D8 version:

  • Allow sorting on fulltext fields, but not on multi-valued fields. Let the service classes figure out a way to support it.
  • Allow sorting on all fields, even multi-valued. Again, the service classes have to figure out, how.
  • Have no rule against it in the framework in general, but allow service classes to fail on or ignore sorts on particular fields. (Might be bad UX, if a search suddenly fails because you have set a wrong sort.)
  • Make it optional via a feature (or features) that let service classes advertise what sorting they support. Alternatively, we could introduce a dedicated service class method, canSortOn($field). In both cases, it would add additional complexity to the Views integration, and might be more confusing to users (i.e., site builders) than the current approach.
  • Just leave everything as it is.

For both Solr and the database, having to support sorting for fulltext and/or multi-valued fields would probably mean storing concatenated/condensed/single-valued versions of all such fields internally, thus increasing disk space usage (though, for Solr at least, the field at least wouldn't need to be stored). But it would definitely be possible, I guess.

And, in general, as how critical would you see this? Has the current regulation ever restricted functionality for you, or otherwise been a drawback for your project?

Comments

drunken monkey’s picture

Title: Allow sorts on multi-valued or fulltext fields? » Allow sorts on multi-valued and fulltext fields
Project: Search API » Search API (8.x)
Version: 8.x-1.x-dev »
Component: Framework » Backend
Status: Active » Postponed

Ah, screw it, let's just sort on everything! Andrei is already implementing this for the DB backend, for Solr it should be even less complicated. And if it just isn't possible in some backend, it can still always throw an exception, or ignore the sort.
Committed this in the sandbox now.

  • Commit eb75188 on master, search_api_db by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, search_api_db, views, local-tasks by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...
  • Commit eb75188 on master, search_api_db, views, local-tasks by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, search_api_db, views, local-tasks, 2241429--language_support by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...
drunken monkey’s picture

Status: Postponed » Closed (fixed)

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2253237-search-result-class, 2241429--language_support, htmlfilter by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, 2235381-fix-config-schemas by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, 2230881-test-all-processors by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, issue-2273743 by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2 by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix, 2281233-fix-stopwords by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix, 2281233-fix-stopwords, ignorecase-nick, renamefields by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, 2241429--language_support, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix, 2281233-fix-stopwords, ignorecase-nick, renamefields by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, htmlfilter, issue-2273743, 2268885-fix-validation, synonyms-processor, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, htmlfilter, issue-2273743, 2268885-fix-validation, synonyms-processor, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight, add-aggregation-nick by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, htmlfilter, issue-2273743, 2268885-fix-validation, synonyms-processor, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight, add-aggregation-nick, 2247923-Test_the_RenderedItem_processor by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...

  • Commit eb75188 on master, views, htmlfilter, issue-2273743, 2268885-fix-validation, synonyms-processor, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight, add-aggregation-nick, 2247923-Test_the_RenderedItem_processor, 2286813-fields-processor-plugin-base-test by drunken monkey:
    Issue #2223659 by drunken monkey: Allow sorts on multi-valued and...