title: ElasticSearch - Adjacency matrix & Sum
body: <p>I'm currently learning Elastic, I've created this dataset on french presidentials elections from 1965 to 2017 and I want to query the sum of all the documents matching &quot;tour&quot; = 1 and &quot;election&quot; = 1974.</p>
  <p>I've done this, but it's not working, what I did wrong ?</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;size&quot;: 0,
    &quot;aggs&quot;: {
      &quot;somme_blancs_nuls&quot;: {
        &quot;sum&quot;: {
          &quot;field&quot;: &quot;blancs_nuls&quot;,
          &quot;aggs&quot;: {
            &quot;interactions&quot;: {
              &quot;adjacency_matrix&quot;: {
                &quot;filters&quot;: {
                  &quot;grpA&quot;: {
                    &quot;match&quot;: {
                      &quot;tour&quot;: 1
                    }
                  },
                  &quot;grpB&quot;: {
                    &quot;match&quot;: {
                      &quot;election&quot;: 1974
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  <p>Here's my mapping and a sample document.</p>
  <pre class="lang-json prettyprint-override"><code>// Mapping
  {
      &quot;properties&quot;: {
          &quot;election&quot;: {
              &quot;type&quot;: &quot;integer&quot;
          },
          &quot;tour&quot;: {
              &quot;type&quot;: &quot;integer&quot;
          },
          &quot;code&quot;: {
              &quot;type&quot;: &quot;text&quot;
          },
          &quot;libelle&quot;: {
              &quot;type&quot;: &quot;text&quot;,
              &quot;fields&quot;: {
                  &quot;keyword&quot;: {
                      &quot;type&quot;:&quot;keyword&quot;
                  }
              }
          },
          &quot;inscrits&quot;: {
              &quot;type&quot;: &quot;long&quot;
          },
          &quot;votants&quot;: {
              &quot;type&quot;: &quot;long&quot;
          },
          &quot;exprimes&quot;: {
              &quot;type&quot;: &quot;long&quot;
          },
          &quot;abstentions&quot;: {
              &quot;type&quot;: &quot;long&quot;
          },
          &quot;blancs_nuls&quot;: {
              &quot;type&quot;: &quot;long&quot;
          },
          &quot;candidats&quot;: {
              &quot;type&quot;: &quot;nested&quot;,
              &quot;properties&quot;: {
                  &quot;nom&quot;: {
                      &quot;type&quot;: &quot;text&quot;,
                      &quot;fields&quot;: {
                          &quot;keyword&quot;: {
                              &quot;type&quot;:&quot;keyword&quot;
                          }
                      }
                  },
                  &quot;parti&quot;: {
                      &quot;type&quot;: &quot;text&quot;,
                      &quot;fields&quot;: {
                          &quot;keyword&quot;: {
                              &quot;type&quot;:&quot;keyword&quot;
                          }
                      }
                  },
                  &quot;votes&quot;: {
                      &quot;type&quot;: &quot;long&quot;
                  }
              }
          }
      }
  }
  </code></pre>
  <pre class="lang-json prettyprint-override"><code>// Sample
  {
      &quot;election&quot;: 1965,
      &quot;tour&quot;: 1,
      &quot;code&quot;: &quot;1&quot;,
      &quot;libelle&quot;: &quot;AIN&quot;,
      &quot;inscrits&quot;: 206496,
      &quot;votants&quot;: 166986,
      &quot;exprimes&quot;: 165555,
      &quot;abstentions&quot;: 39510,
      &quot;blancs_nuls&quot;: 1431,
      &quot;candidats&quot;: [
          {
          &quot;nom&quot;: &quot;François MITTERRAND&quot;,
          &quot;parti&quot;: &quot;CIR&quot;,
          &quot;votes&quot;: 50418
          },
          {
          &quot;nom&quot;: &quot;Charles DE GAULLE&quot;,
          &quot;parti&quot;: &quot;UNR&quot;,
          &quot;votes&quot;: 71246
          },
          {
          &quot;nom&quot;: &quot;Jean LECANUET&quot;,
          &quot;parti&quot;: &quot;MRP&quot;,
          &quot;votes&quot;: 30416
          },
          {
          &quot;nom&quot;: &quot;Jean-Louis TIXIER-VIGNANCOUR&quot;,
          &quot;parti&quot;: &quot;EXD&quot;,
          &quot;votes&quot;: 8317
          },
          {
          &quot;nom&quot;: &quot;Pierre MARCILHACY&quot;,
          &quot;parti&quot;: &quot;DVD&quot;,
          &quot;votes&quot;: 3006
          },
          {
          &quot;nom&quot;: &quot;Marcel BARBU&quot;,
          &quot;parti&quot;: &quot;DIV&quot;,
          &quot;votes&quot;: 2152
          }
      ]
  }
  </code></pre>
  <p>Thanks in advance :)</p>