<p dir="auto">Adding <code class="notranslate">search_after</code> option to the search api will allow better deep pagination support for search request that don't use the scroll api.</p>
<p dir="auto">The <code class="notranslate">search_after</code> option should be used to hold the last seen sort value for each search request being executed with the same query (just like updating the <code class="notranslate">from</code> option). Although in this case we don't keep open a consistent view of all the shards, like we do with scroll search, it is a good alternative for deep pagination for normal search requests that use <code class="notranslate">from</code> option. (actually the only one that doesn't cause jvm heap issues without maintaining open search contexts during subsequent scroll requests)</p>
<p dir="auto">The settings are as follows:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="   &quot;products_v2&quot;: {
      &quot;settings&quot;: {
         &quot;index&quot;: {
            &quot;creation_date&quot;: &quot;1475684313640&quot;,
            &quot;analysis&quot;: {
               &quot;filter&quot;: {
                  &quot;english_keywords&quot;: {
                     &quot;ignore_case&quot;: &quot;true&quot;,
                     &quot;type&quot;: &quot;keyword_marker&quot;,
                     &quot;keywords_path&quot;: &quot;analysis/exclude_stem.txt&quot;
                  },
                  &quot;synonym_expand&quot;: {
                     &quot;type&quot;: &quot;synonym&quot;,
                     &quot;synonyms_path&quot;: &quot;analysis/synonyms.txt&quot;
                  },
                  &quot;english_stemmer&quot;: {
                     &quot;type&quot;: &quot;stemmer&quot;,
                     &quot;language&quot;: &quot;english&quot;
                  },
                  &quot;english_stop&quot;: {
                     &quot;type&quot;: &quot;stop&quot;,
                     &quot;stopwords&quot;: &quot;_english_&quot;
                  },
                  &quot;english_possessive_stemmer&quot;: {
                     &quot;type&quot;: &quot;stemmer&quot;,
                     &quot;language&quot;: &quot;possessive_english&quot;
                  },
               &quot;char_filter&quot;: {
                  &quot;stem_mapping&quot;: {
                     &quot;type&quot;: &quot;mapping&quot;,
                     &quot;mappings_path&quot;: &quot;analysis/char_mappings.txt&quot;
                  }
               },
               &quot;analyzer&quot;: {
                  &quot;synonyms_expand&quot;: {
                     &quot;filter&quot;: [
                        &quot;synonym_expand&quot;,
                        &quot;english_possessive_stemmer&quot;,
                        &quot;lowercase&quot;,
                        &quot;english_stop&quot;,
                        &quot;english_keywords&quot;,
                        &quot;english_stemmer&quot;
                     ],
                 &quot;type&quot;: &quot;custom&quot;,
                  &quot;tokenizer&quot;: &quot;standard&quot;
                  }
                }
         }
}"><pre class="notranslate"><code class="notranslate">   "products_v2": {
      "settings": {
         "index": {
            "creation_date": "1475684313640",
            "analysis": {
               "filter": {
                  "english_keywords": {
                     "ignore_case": "true",
                     "type": "keyword_marker",
                     "keywords_path": "analysis/exclude_stem.txt"
                  },
                  "synonym_expand": {
                     "type": "synonym",
                     "synonyms_path": "analysis/synonyms.txt"
                  },
                  "english_stemmer": {
                     "type": "stemmer",
                     "language": "english"
                  },
                  "english_stop": {
                     "type": "stop",
                     "stopwords": "_english_"
                  },
                  "english_possessive_stemmer": {
                     "type": "stemmer",
                     "language": "possessive_english"
                  },
               "char_filter": {
                  "stem_mapping": {
                     "type": "mapping",
                     "mappings_path": "analysis/char_mappings.txt"
                  }
               },
               "analyzer": {
                  "synonyms_expand": {
                     "filter": [
                        "synonym_expand",
                        "english_possessive_stemmer",
                        "lowercase",
                        "english_stop",
                        "english_keywords",
                        "english_stemmer"
                     ],
                 "type": "custom",
                  "tokenizer": "standard"
                  }
                }
         }
}
</code></pre></div>
<p dir="auto">The expected result after expansion for synonym is the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /products_v2/_analyze?analyzer=english&amp;text=&quot;jell-o&quot;
{
   &quot;tokens&quot;: [
      {
         &quot;token&quot;: &quot;jell&quot;,
         &quot;start_offset&quot;: 1,
         &quot;end_offset&quot;: 5,
         &quot;type&quot;: &quot;&lt;ALPHANUM&gt;&quot;,
         &quot;position&quot;: 0
      },
      {
         &quot;token&quot;: &quot;o&quot;,
         &quot;start_offset&quot;: 6,
         &quot;end_offset&quot;: 7,
         &quot;type&quot;: &quot;&lt;ALPHANUM&gt;&quot;,
         &quot;position&quot;: 1
      }
   ]
}"><pre class="notranslate"><code class="notranslate">GET /products_v2/_analyze?analyzer=english&amp;text="jell-o"
{
   "tokens": [
      {
         "token": "jell",
         "start_offset": 1,
         "end_offset": 5,
         "type": "&lt;ALPHANUM&gt;",
         "position": 0
      },
      {
         "token": "o",
         "start_offset": 6,
         "end_offset": 7,
         "type": "&lt;ALPHANUM&gt;",
         "position": 1
      }
   ]
}
</code></pre></div>
<p dir="auto">The synonym I put in is jello=&gt;jell-o</p>
<p dir="auto">The result that I get after using the synonym analyzer</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /products_v2/_analyze?analyzer=synonyms_expand&amp;text=&quot;jello&quot;
{
   &quot;tokens&quot;: [
      {
         &quot;token&quot;: &quot;jell-o&quot;,
         &quot;start_offset&quot;: 1,
         &quot;end_offset&quot;: 6,
         &quot;type&quot;: &quot;SYNONYM&quot;,
         &quot;position&quot;: 0
      }
   ]
}"><pre class="notranslate"><code class="notranslate">GET /products_v2/_analyze?analyzer=synonyms_expand&amp;text="jello"
{
   "tokens": [
      {
         "token": "jell-o",
         "start_offset": 1,
         "end_offset": 6,
         "type": "SYNONYM",
         "position": 0
      }
   ]
}
</code></pre></div>
<p dir="auto">This doesn't seem right. I use the english chain after synonyms expanded.<br>
The result should be the same as the one that I get when running:<br>
GET /products_v2/_analyze?analyzer=english&amp;text="jell-o"</p>
<p dir="auto">The reason for this is because the standard analyzer gets applied first and only then do we apply the synonym analyzer</p>
<p dir="auto">What happens:<br>
jello, the standard analyzer gets applied. There is no taken chain<br>
Then the word gets expanded to the synonym analzyer: jell-o<br>
At this point there is no tokenization that happens to jell-o. The word doesn't change.</p>
<p dir="auto">When jell-o gets indexed -  it gets indexed using the english analyzer so "jell o". Therefore it doesn't change.  Is there anyway we can add a standard tokenizer to the chain of analysis after the synonym expansion happens?</p>