k-samuel / faceted-search

PHP Faceted search library
MIT License
205 stars 14 forks source link

ValueIntersectionFilter added #35

Closed k-samuel closed 9 months ago

k-samuel commented 9 months ago

Feature Request

ValueIntersectionFilter

Default Filters example:

Find phones with memory sizes ANY OF (12, 32, 64) AND camera 12m

$filters[] = new ValueFilter(‘size’, [12,32,64]);
$filters[] = new ValueFilter(‘camera’, [12]);

New functionality example:

Search brand "Digma" OR "Pony" where the recommended usage is for portraits AND wildlife

$filters[] = new ValueFilter('brand', ['Digma', 'Pony']); // ANY OF
$filters[] = new ValueIntersectionFilter('usage', ['portraits', 'wildlife']); // portraits AND wildlife 

Self-filtering

Aggregates disables property self-filtering by default. It allow the user to choose another option in the interface.

Example: User wants a phone with 32GB memory, checks the box for the desired option from (16, 32, 64). If self-filtering is enabled, then all other options in the UI will disappear and only 32 will remain. Thus, user will not be able to change his choice.

During aggregation field filter value is used to limit values only other fields. Example: the "size" filter condition uses to limit the list of "brand" field variations.

All depends on your use case of the library. Initially, the library was developed to simplify the construction of a search UI. If you want to use the library at the level of technical analysis, statistics, etc. , then enabling self-filtering can help you to get expected results.

$query = (new AggregationQuery())->filters($filters)->countItems()->sort()->selfFiltering(true);
janroz commented 9 months ago

Thanx! I look at it in this week, I hope I can help