<p dir="auto">I think when setting <code class="notranslate">suggest_mode</code> to be <code class="notranslate">missing</code>, no suggestion should be returned if the term exists in the index. But it turns out not to behave like my expectation. Is it a bug or anything?</p>
<p dir="auto">Below is what i did. (with elasticsearch 1.5)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# remove all
$ curl -XDELETE elastic:9200/*
{&quot;acknowledged&quot;:true}

# index two documents
$ curl -XPOST elastic:9200/my_index/my_type -d '{&quot;name&quot;: &quot;shinagawa hotel&quot;}'
{&quot;_index&quot;:&quot;my_index&quot;,&quot;_type&quot;:&quot;my_type&quot;,&quot;_id&quot;:&quot;AU4FdpnwDWV1B-oz3tLK&quot;,&quot;_version&quot;:1,&quot;created&quot;:true}
$ curl -XPOST elastic:9200/my_index/my_type -d '{&quot;name&quot;: &quot;shirakawa hotel&quot;}'
{&quot;_index&quot;:&quot;my_index&quot;,&quot;_type&quot;:&quot;my_type&quot;,&quot;_id&quot;:&quot;AU4Fdta7DWV1B-oz3tLL&quot;,&quot;_version&quot;:1,&quot;created&quot;:true}"><pre class="notranslate"><code class="notranslate"># remove all
$ curl -XDELETE elastic:9200/*
{"acknowledged":true}

# index two documents
$ curl -XPOST elastic:9200/my_index/my_type -d '{"name": "shinagawa hotel"}'
{"_index":"my_index","_type":"my_type","_id":"AU4FdpnwDWV1B-oz3tLK","_version":1,"created":true}
$ curl -XPOST elastic:9200/my_index/my_type -d '{"name": "shirakawa hotel"}'
{"_index":"my_index","_type":"my_type","_id":"AU4Fdta7DWV1B-oz3tLL","_version":1,"created":true}
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ cat search.json"><pre class="notranslate"><code class="notranslate">$ cat search.json
</code></pre></div>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;explain&quot;: true,
    &quot;query&quot;: {
        &quot;match&quot;: {
            &quot;name&quot;: {
                &quot;query&quot;: &quot;shinagawa&quot;
            }
        }
    },
    &quot;suggest&quot;: {
        &quot;my-suggest&quot;: {
            &quot;text&quot;: &quot;shinagawa&quot;,
            &quot;term&quot;: {
                &quot;field&quot;: &quot;name&quot;,
                &quot;suggest_mode&quot;: &quot;missing&quot;
            }
        }
    }
}"><pre class="notranslate">{
    <span class="pl-ent">"explain"</span>: <span class="pl-c1">true</span>,
    <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match"</span>: {
            <span class="pl-ent">"name"</span>: {
                <span class="pl-ent">"query"</span>: <span class="pl-s"><span class="pl-pds">"</span>shinagawa<span class="pl-pds">"</span></span>
            }
        }
    },
    <span class="pl-ent">"suggest"</span>: {
        <span class="pl-ent">"my-suggest"</span>: {
            <span class="pl-ent">"text"</span>: <span class="pl-s"><span class="pl-pds">"</span>shinagawa<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"term"</span>: {
                <span class="pl-ent">"field"</span>: <span class="pl-s"><span class="pl-pds">"</span>name<span class="pl-pds">"</span></span>,
                <span class="pl-ent">"suggest_mode"</span>: <span class="pl-s"><span class="pl-pds">"</span>missing<span class="pl-pds">"</span></span>
            }
        }
    }
}</pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ curl elastic:9200/my_index/_search?pretty -d@search.json"><pre class="notranslate"><code class="notranslate">$ curl elastic:9200/my_index/_search?pretty -d@search.json
</code></pre></div>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;took&quot; : 7,
  &quot;timed_out&quot; : false,
  &quot;_shards&quot; : {
    &quot;total&quot; : 5,
    &quot;successful&quot; : 5,
    &quot;failed&quot; : 0
  },
  &quot;hits&quot; : {
    &quot;total&quot; : 1,
    &quot;max_score&quot; : 0.19178301,
    &quot;hits&quot; : [ {
      &quot;_shard&quot; : 3,
      &quot;_node&quot; : &quot;7UoDQJWRQYqF4Gjq94LiMg&quot;,
      &quot;_index&quot; : &quot;my_index&quot;,
      &quot;_type&quot; : &quot;my_type&quot;,
      &quot;_id&quot; : &quot;AU4FdpnwDWV1B-oz3tLK&quot;,
      &quot;_score&quot; : 0.19178301,
      &quot;_source&quot;:{&quot;name&quot;: &quot;shinagawa hotel&quot;},
      &quot;_explanation&quot; : {
        &quot;value&quot; : 0.19178301,
        &quot;description&quot; : &quot;weight(name:shinagawa in 0) [PerFieldSimilarity], result of:&quot;,
        &quot;details&quot; : [ {
          &quot;value&quot; : 0.19178301,
          &quot;description&quot; : &quot;fieldWeight in 0, product of:&quot;,
          &quot;details&quot; : [ {
            &quot;value&quot; : 1.0,
            &quot;description&quot; : &quot;tf(freq=1.0), with freq of:&quot;,
            &quot;details&quot; : [ {
              &quot;value&quot; : 1.0,
              &quot;description&quot; : &quot;termFreq=1.0&quot;
            } ]
          }, {
            &quot;value&quot; : 0.30685282,
            &quot;description&quot; : &quot;idf(docFreq=1, maxDocs=1)&quot;
          }, {
            &quot;value&quot; : 0.625,
            &quot;description&quot; : &quot;fieldNorm(doc=0)&quot;
          } ]
        } ]
      }
    } ]
  },
  &quot;suggest&quot; : {
    &quot;my-suggest&quot; : [ {
      &quot;text&quot; : &quot;shinagawa&quot;,
      &quot;offset&quot; : 0,
      &quot;length&quot; : 9,
      &quot;options&quot; : [ {
        &quot;text&quot; : &quot;shirakawa&quot;,
        &quot;score&quot; : 0.7777778,
        &quot;freq&quot; : 1
      } ]
    } ]
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"took"</span> : <span class="pl-c1">7</span>,
  <span class="pl-ent">"timed_out"</span> : <span class="pl-c1">false</span>,
  <span class="pl-ent">"_shards"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"successful"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"failed"</span> : <span class="pl-c1">0</span>
  },
  <span class="pl-ent">"hits"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">1</span>,
    <span class="pl-ent">"max_score"</span> : <span class="pl-c1">0.19178301</span>,
    <span class="pl-ent">"hits"</span> : [ {
      <span class="pl-ent">"_shard"</span> : <span class="pl-c1">3</span>,
      <span class="pl-ent">"_node"</span> : <span class="pl-s"><span class="pl-pds">"</span>7UoDQJWRQYqF4Gjq94LiMg<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_index"</span> : <span class="pl-s"><span class="pl-pds">"</span>my_index<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_type"</span> : <span class="pl-s"><span class="pl-pds">"</span>my_type<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_id"</span> : <span class="pl-s"><span class="pl-pds">"</span>AU4FdpnwDWV1B-oz3tLK<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_score"</span> : <span class="pl-c1">0.19178301</span>,
      <span class="pl-ent">"_source"</span>:{<span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>shinagawa hotel<span class="pl-pds">"</span></span>},
      <span class="pl-ent">"_explanation"</span> : {
        <span class="pl-ent">"value"</span> : <span class="pl-c1">0.19178301</span>,
        <span class="pl-ent">"description"</span> : <span class="pl-s"><span class="pl-pds">"</span>weight(name:shinagawa in 0) [PerFieldSimilarity], result of:<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"details"</span> : [ {
          <span class="pl-ent">"value"</span> : <span class="pl-c1">0.19178301</span>,
          <span class="pl-ent">"description"</span> : <span class="pl-s"><span class="pl-pds">"</span>fieldWeight in 0, product of:<span class="pl-pds">"</span></span>,
          <span class="pl-ent">"details"</span> : [ {
            <span class="pl-ent">"value"</span> : <span class="pl-c1">1.0</span>,
            <span class="pl-ent">"description"</span> : <span class="pl-s"><span class="pl-pds">"</span>tf(freq=1.0), with freq of:<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"details"</span> : [ {
              <span class="pl-ent">"value"</span> : <span class="pl-c1">1.0</span>,
              <span class="pl-ent">"description"</span> : <span class="pl-s"><span class="pl-pds">"</span>termFreq=1.0<span class="pl-pds">"</span></span>
            } ]
          }, {
            <span class="pl-ent">"value"</span> : <span class="pl-c1">0.30685282</span>,
            <span class="pl-ent">"description"</span> : <span class="pl-s"><span class="pl-pds">"</span>idf(docFreq=1, maxDocs=1)<span class="pl-pds">"</span></span>
          }, {
            <span class="pl-ent">"value"</span> : <span class="pl-c1">0.625</span>,
            <span class="pl-ent">"description"</span> : <span class="pl-s"><span class="pl-pds">"</span>fieldNorm(doc=0)<span class="pl-pds">"</span></span>
          } ]
        } ]
      }
    } ]
  },
  <span class="pl-ent">"suggest"</span> : {
    <span class="pl-ent">"my-suggest"</span> : [ {
      <span class="pl-ent">"text"</span> : <span class="pl-s"><span class="pl-pds">"</span>shinagawa<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"offset"</span> : <span class="pl-c1">0</span>,
      <span class="pl-ent">"length"</span> : <span class="pl-c1">9</span>,
      <span class="pl-ent">"options"</span> : [ {
        <span class="pl-ent">"text"</span> : <span class="pl-s"><span class="pl-pds">"</span>shirakawa<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"score"</span> : <span class="pl-c1">0.7777778</span>,
        <span class="pl-ent">"freq"</span> : <span class="pl-c1">1</span>
      } ]
    } ]
  }
}</pre></div>
<p dir="auto">Here <code class="notranslate">shinagawa</code> is in the index of <code class="notranslate">name</code> field, but suggestion to it is not excluded.</p>
<p dir="auto">I have found a few odd cases where the phrase suggester with suggest_mode: "missing" generates a suggestion even though the query returns results. I am querying across two indexes but the query term only exists in one of the indexes. I get the search results I expect, but I do not expect to get a suggestion.</p>
<p dir="auto">I am trying to come up with a curl recreation but I haven't been able to reproduce it yet in a smaller corpus.</p>
<p dir="auto">I believe what is happening is that the phrase suggestions are getting merged together in the same way the query results are merged together across multiple indexes. If I have query results from test_1 and no results from test_2, then I expect to see results from test_1. But if I have a suggestion from test_1 and no suggestion from test_2 (due to suggest_mode: "missing"), I do not expect to see a suggestion.</p>