Search result based on a specific field in a related entry in a matrix On this product list page: https://www.alfa.no/shop/skisko/ I need to add a size filter, to only show products that are size 45 for example AND that are in stock.

The structure is built with products and productVariants in separate channels, and productVariants (individual shoe sizes) are added to the product inside a matrix field (colorVariants), with sizes as related productVariants entries to each color. All those words look a little something like this:
https://www.dropbox.com/s/2kyvfxq7xv843v6/Screenshot_2014-10-23_09_53_00.png?dl=0

So what I need in the template is to search for products that have a related productVariant in the colorVariants matrix, matching 45 in the variantSize field AND > 0 in the variantStock field.

I have only come as far as being able to list products that match the size in the matrix, with a way too simple search. It searches for the size in the colorVariants matrix field, but the approach is not targeting specific fields, like stock, in the related productVariants entries in the colorVariants matrix:

{% set filteredProductList = productList.search('colorVariants:45') %}
Yes, you're right to better not use the search parameter for such things.

Instead get all the product variants that match your criteria first (e.g. size, color) and then query for all related products. Be careful with the field parameter, as your relation is between a Matrix field and your product variant entries.

Code is not tested (as you might guess, hehe):

{% set category = craft.categories.slug('skisko').first() %}

{% set sizeParam = craft.request.getParam('size') %}
{% set colorParam = craft.request.getParam('color') %}

{#
 # Get product variants matching our search
 #}

{% set variantParams = {
    section: 'productVariants',
    variantStock: '&gt; 0',
    variantSize: sizeParam,
    variantColor: colorParam,
} %}

{% set variants = craft.entries(variantParams) %}

{#
 # Get the products related to these variants
 #}

{% set productParams = {
    section: 'products',    
    relatedTo: [
        'and',
        {
            targetElement: variants,
            field: 'colorVariants.myRelationField',
        },
        {
            targetElement: category,
            field: 'myCategoryRelationField',
        }
    ]
} %}

{% set products = craft.entries(productParams) %}