Skip to content

3.1.0

Compare
Choose a tag to compare
@k-samuel k-samuel released this 14 Jun 20:09
· 36 commits to master since this release
ab8a3bb

Exclude Filters

Feature Request

  • ExcludeValueFilter and ExcludeRageFilter added
  • Updated examples demonstrates the use of most of the library's functions
  • Added sorting inside RangeIndexer's sets

New filters allows to select values ​​and ranges to exclude from search results.
In some cases, such feature is convenient for users, especially when their search comes from understanding what they definitely do not want to see.

Usage is similar to regular filters:

// ....
<?php
$query = (new AggregationQuery())
          ->filters([
                new ExcludeValueFilter('color', ['green']), // remove products with green color from results
                new ValueFilter('size', [41,42]),
          ])
          // Count items for each acceptable filter value (slower)
          ->countItems()
          // Sort results by fields and values
          ->sort();
// ...

Notes

ExcludeValueFilter slightly slows down the search (Query), but speeding up the construction of aggregates. Considering that aggregates are much slower than searches, the functionality in general has a positive effect on performance.

In order to organize user-friendly behavior, additional sorting is needed within the RangeIndexer ranges. Sorting requires additional resources during index construction, and does not affect the performance of subsequent use of indexes.

Sorting within ranges is possible only during the initial creating of index, since the connection with the real value is lost. Therefore, when using the RangeIndexer, you should not use adding new single values after a complete rebuild. As a workaround new values will be added to the end of range and be sorted only inside new values. This is relevant only for cases with sorting by field indexed by RangeIndexer.