Filter entry query by a custom field value I have a channel, 'pages'. Within that channel is a dropdown 'navigation'. The values in the dropdown are 'mainNavigation' and 'hidden'.
I'm trying to set an entry query that only pulls entries where the navigation value is 'mainNavigation'.
This is the code I'm using, and I'm getting no results:
{% set nav = craft.entries.section('pages').search('navigation:&quot;mainNavigation&quot;').all() %}
{% for link in nav %}
    {{link.title}} 
{% endfor %}

I know this should work. I've done it before. I copied the working code from another site, and copied the field name and value directly from the CP. I've stripped everything else out of the template. But no matter what I do, I get no results.
Has this functionality changed recently?
Your code should work. Make sure that your Settings → Fields → Navigation has Use this field’s values as search keywords checked.
Once you're sure it is checked, run ./craft resave/entries --update-search-index and it should start working.
Note that instead of searching, you could use:
{% set nav = craft.entries()
    .section('pages')
    .navigation('mainNavigation')
    .all() %}