The return value of searches (documented for \Drupal\search_api\Query\QueryInterface::execute()) is currently one huge array, which should of course be split up. We want a class for the result as a whole, and a class for each returned result (with methods for getting the ID, the datasource (and maybe the raw, datasource-specific ID?), the score, the original item, etc.). Also, of course, a method for adding/reading additional results data, where, e.g., facets could be returned.

Likewise, during indexing we extract the item data into the typical huge D7 arrays, with settings keys ($item[#something']) used for passing the original object, datasource ID and item ID (and possibly other metadata later).
This should be switched to a proper OO implementation, using classed objects for each item, and for the fields contained within. The item object should have methods for retrieving the original object, datasource ID and item ID, as well as methods for getting/setting arbitrary metadata. Implementing Traversable might also be a good idea.
We might also look at whether it makes sense for the item class (resp. its interface – both classes should of course also have interfaces) to inherit from ComplexDataInterface, and the field class from TypedDataInterface.

The question then is also whether both indexing and result items should use the same class.

Comments

Berdir’s picture

If we want to use the same classes, should we postpone it on #2252079: Switch to proper objects for extracted items?

das-peter’s picture

Assigned: Unassigned » das-peter

  • Commit 9b9ec41 on 2253237-search-result-class by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
das-peter’s picture

Component: Backend » Framework
Assigned: das-peter » Unassigned

I'm not sure when I'm able to continue here - so unassigning me for now :|

drunken monkey’s picture

Title: Add proper classes for search results » Add proper classes for indexed items and search results
Assigned: Unassigned » drunken monkey
Issue summary: View changes

I hope I'll be able to finally implement this this week.

(Also, merging #2252079: Switch to proper objects for extracted items into this issue.)

  • Commit 8f72640 on master by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...
  • Commit 9b9ec41 on master, 2253237-search-result-class by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
drunken monkey’s picture

Status: Active » Fixed

Almost unbelievable, but I finally made it. Was quite a bit more than anticipated, but at least I managed to finish before the sprint …

  • Commit 8f72640 on master, 2230925-server-tasks by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...
  • Commit 9b9ec41 on master, 2253237-search-result-class, 2230925-server-tasks by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2230925-server-tasks, 2235381-fix-config-schemas-2 by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 2230925-server-tasks, 2235381-fix-config-schemas-2 by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix, 2281233-fix-stopwords by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 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 #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 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 das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 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 #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 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 das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 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 #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight, add-aggregation-nick by das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight, add-aggregation-nick by drunken monkey:
    Issue #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 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 das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 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 #2253237 by drunken monkey, das-peter, amateescu: Added proper...

  • Commit 9b9ec41 on master, 2253237-search-result-class, 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 das-peter:
    Issue #2253237: Add proper classes for search results
    Initial commit.
    
  • Commit 8f72640 on master, 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 #2253237 by drunken monkey, das-peter, amateescu: Added proper...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.