title: How to boost documents matching one of the query_string
body: <p>Elasticsearch newbie here. I'm trying to lookup documents that has <code>foo</code> in its name but want to prioritize that ones having <code>bar</code> as well i.e. those with <code>bar</code> will be at the top of the list. The result doesn't have the ones with bar at the top. <code>boost</code> here doesn't seem to have any effect, likely I'm not understanding how boost works here. Appreciate any help here.</p>
  <pre><code>query: {
      bool: {
          should: [
              {
                  query_string: {
                      query: `name:foo*bar*`,
                      boost: 5
                  }
              },
              {
                  query_string: {
                      query: `name:*foo*`,
                  }
              }
          ]
      }
  }
  </code></pre>
  <p>Sample document structure:</p>
  <pre><code>{
      &quot;name&quot;: &quot;foos, one two three&quot;,
      &quot;type&quot;: &quot;car&quot;,
      &quot;age&quot;: 10 
  }
  {
      &quot;name&quot;: &quot;foos, one two bar three&quot;,
      &quot;type&quot;: &quot;train&quot;,
      &quot;age&quot;: 30 
  }
  </code></pre>
  <p>Index mapping</p>
  <pre><code>{
      &quot;detail&quot;: {
          &quot;mappings&quot;: {
              &quot;properties&quot;: {
                  &quot;category&quot;: {
                      &quot;type&quot;: &quot;text&quot;,
                      &quot;fields&quot;: {
                          &quot;keyword&quot;: {
                              &quot;type&quot;: &quot;keyword&quot;,
                              &quot;ignore_above&quot;: 256
                          }
                      }
                  },
                  &quot;name&quot;: {
                      &quot;type&quot;: &quot;text&quot;,
                      &quot;fields&quot;: {
                          &quot;keyword&quot;: {
                              &quot;type&quot;: &quot;keyword&quot;,
                              &quot;ignore_above&quot;: 256
                          }
                      }
                  },
                  &quot;servings&quot;: {
                      &quot;properties&quot;: {
                          &quot;name&quot;: {
                              &quot;type&quot;: &quot;text&quot;,
                              &quot;fields&quot;: {
                                  &quot;keyword&quot;: {
                                      &quot;type&quot;: &quot;keyword&quot;,
                                      &quot;ignore_above&quot;: 256
                                  }
                              }
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>