- Issue created by @bojan_dev
- Merge request !160#3468367: Update condition which determines if entity loading should occur → (Closed) created by bojan_dev
- Status changed to Needs review
4 months ago 3:05pm 15 August 2024 - Status changed to Needs work
4 months ago 2:08pm 18 August 2024 - 🇦🇹Austria drunken monkey Vienna, Austria
Thanks for suggesting this improvement.
You’re right that it doesn’t make sense to load entities just because they are missing fields that cannot have a value anyways. However, I fear that it’s a lot trickier to determine whether that is indeed the case than the simple check in your MR. In that line,
$row
is just a\Drupal\search_api\Plugin\views\ResultRow
object, so will hardly ever have a$row->{$dependent}
property. (This is probably also why the tests are failing.)I think to properly check whether the row might have the property in question, you will always need to load the entity.
I also don’t quite understand your use case, to be honest. If your view only lists that single field, why include nodes that don’t have it at all? Why not add a “associated reference field: not empty” filter to the view?
- 🇳🇱Netherlands bojan_dev
I think to properly check whether the row might have the property in question, you will always need to load the entity
I rather find a solution to not load entities, this makes even more sense when using Search API Solr, where you actually want to only use Solr instead of DB queries.
I also don’t quite understand your use case, to be honest. If your view only lists that single field, why include nodes that don’t have it at all? Why not add a “associated reference field: not empty” filter to the view?
For example imagine a specific CT that has tags or a category and you want to display the taxonomy label it in the search results. I don't want to add that filter because that would mean I won't get other CT's in the search. You need to see it as search results that for one or more CT's has more info to show.
- Status changed to Closed: duplicate
4 months ago 12:00pm 19 August 2024 - 🇳🇱Netherlands bojan_dev
Found related issue: ✨ Allow to index empty fields Active
I will try to build the kill switch and contribute in the other issue.