Questions about facets
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Questions about facets
I am trying to figure out how facets work over the API.
In general they work, but I would like to limit the facet options that are applicable to the subselection of products.
How can I achieve that?
Now I am using a query, which returns 6 products out of 13 products:
This query result returns me under 'included' the attributes that are visible on this image:

The problem is that there are more facets available on the next page (such as Manufacturer = HP and so on...).
How can I get full list of available facets that take into account all the filters but exclude paging?
That one I resolved with aggregation (http://localhost:8000/jsonapi/product?aggregate=index.attribute.id)
In general they work, but I would like to limit the facet options that are applicable to the subselection of products.
How can I achieve that?
Now I am using a query, which returns 6 products out of 13 products:
Code: Select all
https://aimeos.priit.yt.lan/jsonapi/product?include=attribute%2Cmedia%2Cprice%2Cproduct%2Cproduct%2Fproperty%2Ctext%2Ccatalog%2Csupplier%2Cstock%2Cproperty%2Cproduct%2Fproperty%2Ftype%2Cattribute%2Ftype&page%5Blimit%5D=6&page%5Boffset%5D=0The problem is that there are more facets available on the next page (such as Manufacturer = HP and so on...).
How can I get full list of available facets that take into account all the filters but exclude paging?
That one I resolved with aggregation (http://localhost:8000/jsonapi/product?aggregate=index.attribute.id)
Last edited by matish on 24 Nov 2025, 08:58, edited 1 time in total.
Re: Questions about facets
Another thing that came up:
Consider the following query:
Here are the explanations for each attribute ID:
I would like to select all results where (manufacturer.dell OR manufacturer.hp) AND (color.white OR color.black).
How can I make a query that would achieve that? The query that I have above does not have AND condition in the middle.
Consider the following query:
Code: Select all
https://aimeos.priit.yt.lan/jsonapi/product?include=attribute,media,price,product,product/property,text,catalog,supplier,stock,property,product/property/type,attribute/type
&page[limit]=6
&page[offset]=0
&filter[f_optid][0]=14
&filter[f_optid][1]=11
&filter[f_optid][2]=16
&filter[f_optid][3]=17
Code: Select all
14 = color.black
11 = color.white
16 = manufacturer.dell
17 = manufacturer.hp
How can I make a query that would achieve that? The query that I have above does not have AND condition in the middle.
Re: Questions about facets
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
Re: Questions about facets
I did try with that, but that one seems to result in a query:
But I need:
Code: Select all
where (manufacturer.dell OR manufacturer.hp) OR (color.white OR color.black).
Code: Select all
where (manufacturer.dell OR manufacturer.hp) AND (color.white OR color.black).
Re: Questions about facets
Please have a look at the linked documentation. The f_oneid requires a different filter structure:
Code: Select all
filter[f_oneid][color][]=...Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
Re: Questions about facets
aimeos wrote: ↑24 Nov 2025, 13:53 Please have a look at the linked documentation. The f_oneid requires a different filter structure:Code: Select all
filter[f_oneid][color][]=...
Sorry about the confusion. I took another look and got it working now. Thanks!
Code: Select all
https://aimeos.priit.yt.lan/jsonapi/product
?include=attribute,media,price,product,product/property,text,catalog,supplier,stock,property,product/property/type,attribute/type
&page[limit]=6
&page[offset]=0
&filter[f_oneid][color][0]=13
&filter[f_oneid][vendor][0]=16
&filter[f_oneid][vendor][1]=17
Re: Questions about facets
I would like to use min-price...max-price facet too. Is it possible to know what is the minimum and maximum price for the current subselection of products excluding paging?
Re: Questions about facets
This wasn't possible up to now. The "aimeos/ai-client-jsonapi:2025.10.x-dev" branch contains the changes to use:
Can you give it a try?
Code: Select all
/jsonapi/product?aggregate=price:min
/jsonapi/product?aggregate=price:max
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
Re: Questions about facets
Thanks! It works.aimeos wrote: ↑26 Nov 2025, 13:15 This wasn't possible up to now. The "aimeos/ai-client-jsonapi:2025.10.x-dev" branch contains the changes to use:Can you give it a try?Code: Select all
/jsonapi/product?aggregate=price:min /jsonapi/product?aggregate=price:max
But there is another problem that I am creating right here. I am using HTMX for the UI and it returns full HTML of the page fragment under investigation. For that single HTML fragment I need to make 4 API requests + 2 extra from the post above + some extra if I implement category filtration as well. This amount of requests is a bit too much in my opinion.
Maybe you know a good way to solve it.
Code: Select all
Load all possible facets
1) /jsonapi/attribute?include=media,text,attribute/type
Filter all products
2) /jsonapi/product?include=attribute,media,price,product,product/property,text,catalog,supplier,stock,property,product/property/type,attribute/type&page[limit]=6&page[offset]=6&filter[f_oneid][vendor][0]=15&filter[f_oneid][vendor][1]=16
Read out all facet counts
3) /jsonapi/product?include=attribute,media,price,product,product/property,text,catalog,supplier,stock,property,product/property/type,attribute/type&filter[f_oneid][vendor][0]=15&filter[f_oneid][vendor][1]=16&aggregate=index.attribute.id
Read out all category counts
4) /jsonapi/product?include=attribute,media,price,product,product/property,text,catalog,supplier,stock,property,product/property/type,attribute/type&filter[f_oneid][vendor][0]=15&filter[f_oneid][vendor][1]=16&aggregate=index.catalog.id
Re: Questions about facets
This is static and needs to be loaded only once, so you can cache it.matish wrote: ↑26 Nov 2025, 13:38Code: Select all
Load all possible facets 1) /jsonapi/attribute?include=media,text,attribute/type
All others depend on the user action and you can only perform the requests in parallel.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,