title: Elasticsearch score from 0 to 1 for searching similar documents to the one that exists
body: <p>Need to calculate relative score from 0 to 1 when searching similar documents to existing one?
  So existing one has score 1, and all other matching documents score should be calculated according to this and score will be &lt;= 1. But existing document should be excluded from the search. Is it possible to do it on elasticsearch side, not just calculating score manually in a programming language like:</p>
  <pre><code>match_doc_score/search_doc_score
  </code></pre>
  <p>Let's imagine we have index <code>person</code> with mapping:</p>
  <pre><code>{
    &quot;properties&quot;: {
      &quot;person_id&quot;: {
        &quot;type&quot;: &quot;keyword&quot;
      },
      &quot;fullname&quot;: {
        &quot;type&quot;: &quot;text&quot;
      },
      &quot;email&quot;: {
        &quot;type&quot;: &quot;keyword&quot;
      },
      &quot;phone&quot;: {
        &quot;type&quot;: &quot;keyword&quot;
      },
      &quot;country_of_birth&quot;: {
        &quot;type&quot;: &quot;keyword&quot;
      }
    }
  }
  </code></pre>
  <p>And I have 3 persons inside the index:
  Person 1:</p>
  <pre><code>{
    &quot;person_id&quot;: 1,
    &quot;fullname&quot;: &quot;John Snow&quot;,
    &quot;email&quot;: &quot;john@gmail.com&quot;,
    &quot;phone&quot;: &quot;111-11-11&quot;,
    &quot;country_of_birth&quot;: &quot;Denmark&quot;
  }
  </code></pre>
  <p>Person 2:</p>
  <pre><code>{
    &quot;person_id&quot;: 2,
    &quot;fullname&quot;: &quot;Snow John&quot;,
    &quot;email&quot;: &quot;john@gmail.com&quot;,
    &quot;phone&quot;: &quot;222-22-22&quot;,
    &quot;country_of_birth&quot;: &quot;Denmark&quot;
  }
  </code></pre>
  <p>Person 3:</p>
  <pre><code>{
    &quot;person_id&quot;: 3,
    &quot;fullname&quot;: &quot;Peter Wislow&quot;,
    &quot;email&quot;: &quot;peter@gmail.com&quot;,
    &quot;phone&quot;: &quot;111-11-11&quot;,
    &quot;country_of_birth&quot;: &quot;Denmark&quot;
  }
  </code></pre>
  <p>We find persons that are similar to Person 1 by this query:</p>
  <pre><code>{
      &quot;query&quot;: {
          &quot;bool&quot;: {
              &quot;should&quot;: [
                  {
                      &quot;match&quot;: {
                          &quot;fullname&quot;: {
                              &quot;query&quot;: &quot;John Snow&quot;,
                              &quot;boost&quot;: 6
                          }
                      }
                  },
                  {
                      &quot;term&quot;: {
                          &quot;email&quot;: {
                              &quot;value&quot;: &quot;john@gmail.com&quot;,
                              &quot;boost&quot;: 5
                          }
                      }
                  },
                  {
                      &quot;term&quot;: {
                          &quot;phone&quot;: {
                              &quot;value&quot;: &quot;111-11-11&quot;,
                              &quot;boost&quot;: 4
                          }
                      }
                  },
                  {
                      &quot;term&quot;: {
                          &quot;country_of_birth&quot;: {
                              &quot;value&quot;: &quot;Denmark&quot;,
                              &quot;boost&quot;: 2
                          }
                      }
                  }
              ],
              &quot;must_not&quot;: [
                  {
                      &quot;term&quot;: {
                          &quot;person_id&quot;: 123
                      }
                  }
              ]
          }
      }
  }
  </code></pre>
  <p>As you can see:</p>
  <ul>
  <li>person 1 and person 2 match by: fullname, email, country of birth.</li>
  <li>person 1 and person 3 match by: phone, country of birth.</li>
  </ul>
  <p>Is it possible to have 0..1 scoring if we have order with full match in the index(person 1)?</p>
  <p>I know there is a <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.9//query-dsl-mlt-query.html" rel="nofollow noreferrer">more_like_this</a> query, but in real life search queries can be complicated so <code>more_like_this</code> is not a good option. Even elasticsearch documentation says that if you need more control over the query, then use boolean query combinations.</p>