<p dir="auto">I wrote some code to index/percolate documents, and I have a unit test that creates an index (with a random name) then runs my indexations / search code, then deletes the index. This means that I have percolators with identical IDs in different indexes.</p>
<p dir="auto">When I percolate my documents, I specify a query string for the percolators :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="testindex-2b086e73/doc/a889db29-2409-4174-9425-818eb7293b57?percolate=SourceId:1"><pre class="notranslate"><code class="notranslate">testindex-2b086e73/doc/a889db29-2409-4174-9425-818eb7293b57?percolate=SourceId:1
</code></pre></div>
<p dir="auto">And then the result contains duplicate percolator IDs, as if the index name was ignored :</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;ok&quot; : true,
    &quot;_index&quot; : &quot;testindex-17eecc11&quot;,
    &quot;_type&quot; : &quot;doc&quot;,
    &quot;_id&quot; : &quot;824f26e4-76a6-4b66-9cb2-f3adc0103586&quot;,
    &quot;_version&quot; : 1,
    &quot;matches&quot; : [&quot;1.789&quot;, &quot;1.789&quot;, &quot;1.789&quot;]
}"><pre class="notranslate"><span class="pl-kos">{</span>
    <span class="pl-s">"ok"</span> : <span class="pl-c1">true</span><span class="pl-kos">,</span>
    <span class="pl-s">"_index"</span> : <span class="pl-s">"testindex-17eecc11"</span><span class="pl-kos">,</span>
    <span class="pl-s">"_type"</span> : <span class="pl-s">"doc"</span><span class="pl-kos">,</span>
    <span class="pl-s">"_id"</span> : <span class="pl-s">"824f26e4-76a6-4b66-9cb2-f3adc0103586"</span><span class="pl-kos">,</span>
    <span class="pl-s">"_version"</span> : <span class="pl-c1">1</span><span class="pl-kos">,</span>
    <span class="pl-s">"matches"</span> : <span class="pl-kos">[</span><span class="pl-s">"1.789"</span><span class="pl-kos">,</span> <span class="pl-s">"1.789"</span><span class="pl-kos">,</span> <span class="pl-s">"1.789"</span><span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">But when I don't specify a query for the percolators (?percolate=*) the result only contains one ID as expected.</p>
<p dir="auto"><strong>Edit:</strong><br>
I feel like it's an intended behavior in (<a href="https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java#L345">https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java#L345</a>) is it? If yes, how do I filter percolators only on one documenttype/index?</p>
<p dir="auto">The current synonym token filter behaviour of <em>replacing</em> the token with the synonym doesn't work well with the completion suggester.</p>
<p dir="auto">An option to keep the original token would be helpful.</p>
<p dir="auto">Background:</p>
<p dir="auto">For synonyms to work well with the completion suggester it's important to define synonyms that map to longer tokens, i.e. <code class="notranslate">ne =&gt; north east</code>. (If the synonym mapping was an equivalence instead, such as <code class="notranslate">ne, north east</code>, then someone entering 'north east' would get suggestions for all completions that begin with <code class="notranslate">ne</code> such as <code class="notranslate">neck</code>.)</p>
<p dir="auto">However, when a user enters "ne" they no longer get suggestions that start with "ne". They only get suggestions that start with "north east".</p>
<p dir="auto">A workaround is to explicitly include the short form in the synonym mapping: <code class="notranslate">ne =&gt; north east, ne</code>.</p>
<p dir="auto">However, that becomes painful to setup and maintain because a single mapping like <code class="notranslate">exp, expr, express, expw, expy =&gt; expressway</code> now has to be written out as five separate mappings!</p>
<p dir="auto">I think a simple fix would be to add an option to make the synonym token filter <em>add</em> synonyms instead of <em>replacing</em> the original. Need only apply to the last token in the stream.</p>