title: Solr query for child documents and return parents and filtered children
body: <p>I'm having trouble creating a Solr query to be able to pull out the right documents, and am starting to wonder if what I am trying to do is even possible.</p>
  <p>Currently on Solr 8.9 using a managed schema and every field is using a wildcard field.</p>
  <h1>Firstly what the document looks like</h1>
  <p>(changed names due to redacting internal business language):</p>
  <pre><code>
  {
    &quot;id&quot;: &quot;COUNTY:1&quot;,
    &quot;county_name_s&quot;: &quot;Hertfordshire&quot;,
    &quot;coordinates_s&quot;: {
      &quot;id&quot;: &quot;COUNTY:1COORDINATES:!&quot;,
      &quot;lat_s&quot;: &quot;54.238948&quot;,
      &quot;long_s&quot;: &quot;54.238948&quot;
    },
    &quot;cities&quot;: [
      {
        &quot;id&quot;: &quot;COUNTY:1CITY:1&quot;,
        &quot;city_name_s&quot;: &quot;St Albans&quot;,
        &quot;size&quot;: {
          &quot;id&quot;: &quot;COUNTY:1CITY:1SIZE:1&quot;,
          &quot;sq_ft_s&quot;: &quot;100&quot;,
          &quot;sq_meters_s&quot;: &quot;5879&quot;
        }
      },
      {
        &quot;id&quot;: &quot;COUNTY:1CITY:2&quot;,
        &quot;city_name_s&quot;: &quot;Watford&quot;,
        &quot;size&quot;: {
          &quot;id&quot;: &quot;COUNTY:1CITY:2SIZE:2&quot;,
          &quot;sq_ft_s&quot;: &quot;150&quot;,
          &quot;sq_meters_s&quot;: &quot;10000&quot;
        }
      }
    ],
    &quot;mayor&quot;: {
      &quot;title_s&quot;: &quot;Mrs.&quot;,
      &quot;first_name_s&quot;: &quot;Sheila&quot;,
      &quot;last_name_s&quot;: &quot;Smith&quot;
    }
  }
  
  </code></pre>
  <h2>And what I want to return:</h2>
  <pre><code>{
    &quot;id&quot;: &quot;COUNTY:1&quot;,
    &quot;county_name_s&quot;: &quot;Hertfordshire&quot;,
    &quot;coordinates&quot;: {
      &quot;id&quot;: &quot;COUNTY:1COORDINATES:!&quot;,
      &quot;lat_s&quot;: &quot;54.238948&quot;,
      &quot;long_s&quot;: &quot;54.238948&quot;
    },
    &quot;cities&quot;: [
      {
        &quot;id&quot;: &quot;COUNTY:1CITY:1&quot;,
        &quot;city_name_s&quot;: &quot;St Albans&quot;,
        &quot;size&quot;: {
          &quot;id&quot;: &quot;COUNTY:1CITY:1SIZE:1&quot;,
          &quot;sq_ft_s&quot;: &quot;100&quot;,
          &quot;sq_meters_s&quot;: &quot;5879&quot;
        }
      }
    ],
    &quot;mayor&quot;: {
      &quot;title_s&quot;: &quot;Mrs.&quot;,
      &quot;first_name_s&quot;: &quot;Sheila&quot;,
      &quot;last_name_s&quot;: &quot;Smith&quot;
    }
  }
  </code></pre>
  <p>Basically my goal is to return more or less the entire thing, however with filtering out one of the cities. For example, the condition for the city would be like <code>city_name_s:&quot;St Albans&quot;</code>. So it's to say that I want the parent and all children, however if the child is in that array (ie <code>cities array</code>), then the given field (<code>city_name_s</code>) must equal my defined value, or we don't want that child.</p>
  <h1>Things I've tried:</h1>
  <p>I've basically tried two approaches here:</p>
  <ol>
  <li><p>I've tried to play around with {!child} and {!parent} to get a result that I want. Currently I can only get something from City level or the entire thing as if the filter was not there at county level.</p>
  </li>
  <li><p>I've tried to change values for the childFilter option, with things like:</p>
  <ul>
  <li><code>city_name_s:&quot;St Albans&quot; OR (*:* NOT city_name_s:[* TO *])</code> to try and say 'if field exists it should be this'.</li>
  </ul>
  </li>
  </ol>
  <p>Anyhow I'm starting to run out of ideas with this; been hacking away at it for the past couple of days and not really got any closer.</p>
  <p>Thanks in advance for any help; bashing my head against the wall currently so any suggestions are more than welcome :)</p>