To make the native facet range query the min and max will have already had to be set, and be known. But then the count will also be available with the results collected on the gaps - so the whole plugin becomes redundant.

This plugin also loops over the results, after it's QueryTypePluginBase has already looped over them. That plugin duplicates the behaviour of QueryTypeRangeBase - although for only one use - it, this version, does implement the query itself better.

Looking ahead it makes more sense to collapse all similar behaviour into a PluginBase used by all range types, this can be changed (once) when the native ranges lands.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ekes created an issue. See original summary.

ekes’s picture

Adding related issue, as this would also remove the need for looping over values.

borisson_’s picture

I think that we should probably do a usort to sort by count in the processor. Is that a good idea or should we do #2872360: Distinguish between different facets types first and depend on the sorting of the results when they come back from the backend?

ekes’s picture

To make the native facet range query the min and max will have already had to be set, and be known. But then the count will also be available with the results collected on the gaps - so the whole plugin becomes redundant.

This plugin also loops over the results, after it's QueryTypePluginBase has already looped over them. That plugin duplicates the behaviour of QueryTypeRangeBase - although for only one use - it, this version, does implement the query itself better.

Summary: quick fix for the min/max, alone, put in a sort right at the beginning of this method.

Looking ahead it makes more sense to collapse all similar behaviour into a PluginBase used by all range types, this can be changed (once) when the native ranges lands.

borisson_’s picture

Looking ahead it makes more sense to collapse all similar behaviour into a PluginBase used by all range types, this can be changed (once) when the native ranges lands.

Sounds like a solid plan to get started with improving this!

ekes’s picture

So everything from the Processors preQuery, and postQuery, can go into a query class extending the BaseQuery which has it's own equivalent pre and post method calls. This is also code that largely becomes unnecessary when using native ranges.

This also has the UX bonus of not having processors that are a requirement for specific widgets, so need to be enabled for it to work, but that don't work with other widgets.

There is another bit of code in the processor code though. The build method. This _also_ loops over all the results, and alters the query filters. I'm guessing this is specific to the widget, so could be pushed up to there.

agoradesign’s picture

Status: Active » Needs review
FileSize
767 bytes

The refactoring plan sounds great, but I think, we need a quick bugfix too. Here's a patch that takes care that the results are properly sorted. Of course that may have another negative impact on performance

borisson_’s picture

#7 is a good temporary solution, I think I found/fixed a similar issue in: #2894637: Add testcoverage for range + slider widgets/processors. Or is this something else?

agoradesign’s picture

Took a quick lookt at your patch: seems it is different. You changed the way how you get the min and max. The problem here is that the values in between need to be properly sorted from min to max

borisson_’s picture

Status: Needs review » Active

Setting this one back to active as it's work is now in #2894637: Add testcoverage for range + slider widgets/processors as well. Keeping this one for the bigger refactor.

borisson_’s picture

Title: SliderProcessor: range incorrect min/max - incorrect count » Use native facet range queries with solr
Issue summary: View changes
borisson_’s picture

I updated the title and description of this issue to properly point to what we actually want/need to do in this issue.

@ekes: can you extend the IS to point to how we should properly fix this (we can discuss this in Antwerp/Vienna) maybe we should do this in https://www.drupal.org/node/2896229#comment-12176243? Or at least take that in consideration here?

ekes’s picture

So before I try this out, Joachim's comments in https://www.drupal.org/node/2896229#comment-12176243 do almost certainly overlap.

Before to try and do this it would require some 'black magic' from the configuration to change the facet query, like #2863611: Support range facets. So it seems to me if there is now a concept of 'type' that can be supplied and used to optimise the way the query is made in the back end.

borisson_’s picture

borisson_’s picture

FileSize
2.34 KB

Wrong branch I diffed from.

ekes’s picture

Related:
#2872360: Distinguish between different facets types
#2863611: Support range facets

So like to use consistent strings the value set for ::getSupportedFeatures() like 'search_api_mlt', and probably should be declared 'search_api_location', this could be better 'search_api_range' rather than 'backend_range_grouping'

borisson_’s picture

Status: Active » Needs review
FileSize
1.6 KB
872 bytes
2.35 KB
borisson_’s picture

Ah, only the 2.35kb patch is valid here.

Status: Needs review » Needs work

The last submitted patch, 17: use_native_facet_range-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

borisson_’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update
FileSize
4.92 KB
6.16 KB

Fixes the unit tests, no idea how to fix the integration test yet. I'll need some help to figure out why that one is failing.

Status: Needs review » Needs work

The last submitted patch, 20: use_native_facet_range-2872404-20.patch, failed testing. View results

borisson_’s picture

Issue tags: +Vienna2017
ekes’s picture

Status: Needs work » Needs review
FileSize
6.97 KB
558 bytes

Wasn't being called with the query from fillFacetsWithResults()

ekes’s picture

Perhaps #16 wasn't clear enough, but 'search_api_mlt' is already used (it's the more like this); so I was suggesting something like that. Proposal was search_api_range, but that's possibly confusing now that range is also used for from-to filters, so search-api_granular?

ekes’s picture

FileSize
6.98 KB
513 bytes

Ala

borisson_’s picture

Status: Needs review » Fixed

Woo! Great work @ekes. Thanks for explaining and debugging this and the performance bump this will lead to.

  • borisson_ committed 888290d on 8.x-1.x authored by ekes
    Issue #2872404 by borisson_, ekes: Use native facet range queries with...

Status: Fixed » Closed (fixed)

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