Taxonomy with adjacent cities I have a content type 'company' with a related tax-term: 'city'.
With a view I can search for companies based on 'city' with autocomplete.

Is there a way I can relate adjacent cities into the same tax-term 'city'?
If not, I would have to create a new tax-term into the content type 'company' and select for each company the adjacent cities. That is a lof of work.

Geo lookup is not an option, because we want te select which adjacent cities belongs to a specific city.

For example:
Tax-term: city

City A
-- City B // adjacent city of 'city a'
-- City C // adjacent city of 'city a'
-- City D // adjacent city of 'city a'
City B
City C
City D


As you can see, City B, C and D exists in the tax-term but also are children of 'city A'. It should be an alias, because otherwise the children will have all a different ID, so that won't work.

Hope it is clear ...
I would like to share my own working solution. If you see any improvements, please correct me. That would be helpful. If not I hope this script can be helpful for someone else...

I've created my own module and used this function to alter the query:

&lt;?php

use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\taxonomy\Entity\Term;

function search_cities_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
    // machine_name of view
    if ($view-&gt;id() == 'zoek_een_bedrijf') {
        foreach ($query-&gt;where as &amp;$condition_group) {
            foreach ($condition_group['conditions'] as &amp;$condition) {
                // check which field must be changed
                if ($condition['field'] == 'node__field_stad.field_stad_target_id = :node__field_stad_field_stad_target_id') {
                    $value = $condition['value'];
                    // get ID from taxonomy term
                    $city_id = $value[':node__field_stad_field_stad_target_id'];
                    // load taxonomy term info
                    $term = Term::load($city_id);
                    // load reference field with taxonomy term ID's
                    $term_field = $term-&gt;get('field_aangrenzende_gemeenten')-&gt;getValue();
                    $cities = array();
                    // add ID from parent taxonmy term
                    array_push($cities, $city_id);
                    // add taxonomy terms from reference field (children)
                    //print_r($term_field);
                    foreach ($term_field as $key =&gt; $value) {
                        array_push($cities, $value['target_id']);
                    }
                    // update the condition before sending query to database
                    $condition = array(
                        'field' =&gt; 'node__field_stad.field_stad_target_id',
                        'value' =&gt; $cities,
                        'operator' =&gt; 'IN',
                    );
                }
            }
        }
    }
}