<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>collation – Tools for working with collations. — PyMongo 3.7.2 documentation</title> <link rel="stylesheet" href="../../_static/pydoctheme.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/language_data.js"></script> <script type="text/javascript" src="../../_static/sidebar.js"></script> <link rel="index" title="Index" href="../../genindex.html" /> <link rel="search" title="Search" href="../../search.html" /> <link rel="next" title="collection – Collection level operations" href="collection.html" /> <link rel="prev" title="client_session – Logical sessions for sequential operations" href="client_session.html" /> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="collection.html" title="collection – Collection level operations" accesskey="N">next</a> |</li> <li class="right" > <a href="client_session.html" title="client_session – Logical sessions for sequential operations" accesskey="P">previous</a> |</li> <li class="nav-item nav-item-0"><a href="../../index.html">PyMongo 3.7.2 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="../index.html" >API Documentation</a> »</li> <li class="nav-item nav-item-2"><a href="index.html" accesskey="U"><code class="docutils literal notranslate"><span class="pre">pymongo</span></code> – Python driver for MongoDB</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="module-pymongo.collation"> <span id="collation-tools-for-working-with-collations"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">collation</span></code> – Tools for working with collations.<a class="headerlink" href="#module-pymongo.collation" title="Permalink to this headline">¶</a></h1> <p>Tools for working with <a class="reference external" href="http://userguide.icu-project.org/collation/concepts">collations</a>.</p> <dl class="class"> <dt id="pymongo.collation.Collation"> <em class="property">class </em><code class="descclassname">pymongo.collation.</code><code class="descname">Collation</code><span class="sig-paren">(</span><em>locale</em>, <em>caseLevel=None</em>, <em>caseFirst=None</em>, <em>strength=None</em>, <em>numericOrdering=None</em>, <em>alternate=None</em>, <em>maxVariable=None</em>, <em>normalization=None</em>, <em>backwards=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.collation.Collation" title="Permalink to this definition">¶</a></dt> <dd><table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last"> <li><p class="first"><cite>locale</cite>: (string) The locale of the collation. This should be a string that identifies an <cite>ICU locale ID</cite> exactly. For example, <code class="docutils literal notranslate"><span class="pre">en_US</span></code> is valid, but <code class="docutils literal notranslate"><span class="pre">en_us</span></code> and <code class="docutils literal notranslate"><span class="pre">en-US</span></code> are not. Consult the MongoDB documentation for a list of supported locales.</p> </li> <li><p class="first"><cite>caseLevel</cite>: (optional) If <code class="docutils literal notranslate"><span class="pre">True</span></code>, turn on case sensitivity if <cite>strength</cite> is 1 or 2 (case sensitivity is implied if <cite>strength</cite> is greater than 2). Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p> </li> <li><p class="first"><cite>caseFirst</cite>: (optional) Specify that either uppercase or lowercase characters take precedence. Must be one of the following values:</p> <blockquote> <div><ul class="simple"> <li><a class="reference internal" href="#pymongo.collation.CollationCaseFirst.UPPER" title="pymongo.collation.CollationCaseFirst.UPPER"><code class="xref py py-data docutils literal notranslate"><span class="pre">UPPER</span></code></a></li> <li><a class="reference internal" href="#pymongo.collation.CollationCaseFirst.LOWER" title="pymongo.collation.CollationCaseFirst.LOWER"><code class="xref py py-data docutils literal notranslate"><span class="pre">LOWER</span></code></a></li> <li><a class="reference internal" href="#pymongo.collation.CollationCaseFirst.OFF" title="pymongo.collation.CollationCaseFirst.OFF"><code class="xref py py-data docutils literal notranslate"><span class="pre">OFF</span></code></a> (the default)</li> </ul> </div></blockquote> </li> <li><p class="first"><cite>strength</cite>: (optional) Specify the comparison strength. This is also known as the ICU comparison level. This must be one of the following values:</p> <blockquote> <div><ul class="simple"> <li><a class="reference internal" href="#pymongo.collation.CollationStrength.PRIMARY" title="pymongo.collation.CollationStrength.PRIMARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">PRIMARY</span></code></a></li> <li><a class="reference internal" href="#pymongo.collation.CollationStrength.SECONDARY" title="pymongo.collation.CollationStrength.SECONDARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">SECONDARY</span></code></a></li> <li><a class="reference internal" href="#pymongo.collation.CollationStrength.TERTIARY" title="pymongo.collation.CollationStrength.TERTIARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">TERTIARY</span></code></a> (the default)</li> <li><a class="reference internal" href="#pymongo.collation.CollationStrength.QUATERNARY" title="pymongo.collation.CollationStrength.QUATERNARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">QUATERNARY</span></code></a></li> <li><a class="reference internal" href="#pymongo.collation.CollationStrength.IDENTICAL" title="pymongo.collation.CollationStrength.IDENTICAL"><code class="xref py py-data docutils literal notranslate"><span class="pre">IDENTICAL</span></code></a></li> </ul> </div></blockquote> <p>Each successive level builds upon the previous. For example, a <cite>strength</cite> of <a class="reference internal" href="#pymongo.collation.CollationStrength.SECONDARY" title="pymongo.collation.CollationStrength.SECONDARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">SECONDARY</span></code></a> differentiates characters based both on the unadorned base character and its accents.</p> </li> <li><p class="first"><cite>numericOrdering</cite>: (optional) If <code class="docutils literal notranslate"><span class="pre">True</span></code>, order numbers numerically instead of in collation order (defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>).</p> </li> <li><p class="first"><cite>alternate</cite>: (optional) Specify whether spaces and punctuation are considered base characters. This must be one of the following values:</p> <blockquote> <div><ul class="simple"> <li><a class="reference internal" href="#pymongo.collation.CollationAlternate.NON_IGNORABLE" title="pymongo.collation.CollationAlternate.NON_IGNORABLE"><code class="xref py py-data docutils literal notranslate"><span class="pre">NON_IGNORABLE</span></code></a> (the default)</li> <li><a class="reference internal" href="#pymongo.collation.CollationAlternate.SHIFTED" title="pymongo.collation.CollationAlternate.SHIFTED"><code class="xref py py-data docutils literal notranslate"><span class="pre">SHIFTED</span></code></a></li> </ul> </div></blockquote> </li> <li><p class="first"><cite>maxVariable</cite>: (optional) When <cite>alternate</cite> is <a class="reference internal" href="#pymongo.collation.CollationAlternate.SHIFTED" title="pymongo.collation.CollationAlternate.SHIFTED"><code class="xref py py-data docutils literal notranslate"><span class="pre">SHIFTED</span></code></a>, this option specifies what characters may be ignored. This must be one of the following values:</p> <blockquote> <div><ul class="simple"> <li><a class="reference internal" href="#pymongo.collation.CollationMaxVariable.PUNCT" title="pymongo.collation.CollationMaxVariable.PUNCT"><code class="xref py py-data docutils literal notranslate"><span class="pre">PUNCT</span></code></a> (the default)</li> <li><a class="reference internal" href="#pymongo.collation.CollationMaxVariable.SPACE" title="pymongo.collation.CollationMaxVariable.SPACE"><code class="xref py py-data docutils literal notranslate"><span class="pre">SPACE</span></code></a></li> </ul> </div></blockquote> </li> <li><p class="first"><cite>normalization</cite>: (optional) If <code class="docutils literal notranslate"><span class="pre">True</span></code>, normalizes text into Unicode NFD. Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p> </li> <li><p class="first"><cite>backwards</cite>: (optional) If <code class="docutils literal notranslate"><span class="pre">True</span></code>, accents on characters are considered from the back of the word to the front, as it is done in some French dictionary ordering traditions. Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p> </li> <li><p class="first"><cite>kwargs</cite>: (optional) Keyword arguments supplying any additional options to be sent with this Collation object.</p> </li> </ul> </td> </tr> </tbody> </table> </dd></dl> <dl class="class"> <dt id="pymongo.collation.CollationStrength"> <em class="property">class </em><code class="descclassname">pymongo.collation.</code><code class="descname">CollationStrength</code><a class="headerlink" href="#pymongo.collation.CollationStrength" title="Permalink to this definition">¶</a></dt> <dd><p>An enum that defines values for <cite>strength</cite> on a <a class="reference internal" href="#pymongo.collation.Collation" title="pymongo.collation.Collation"><code class="xref py py-class docutils literal notranslate"><span class="pre">Collation</span></code></a>.</p> <dl class="attribute"> <dt id="pymongo.collation.CollationStrength.PRIMARY"> <code class="descname">PRIMARY</code><em class="property"> = 1</em><a class="headerlink" href="#pymongo.collation.CollationStrength.PRIMARY" title="Permalink to this definition">¶</a></dt> <dd><p>Differentiate base (unadorned) characters.</p> </dd></dl> <dl class="attribute"> <dt id="pymongo.collation.CollationStrength.SECONDARY"> <code class="descname">SECONDARY</code><em class="property"> = 2</em><a class="headerlink" href="#pymongo.collation.CollationStrength.SECONDARY" title="Permalink to this definition">¶</a></dt> <dd><p>Differentiate character accents.</p> </dd></dl> <dl class="attribute"> <dt id="pymongo.collation.CollationStrength.TERTIARY"> <code class="descname">TERTIARY</code><em class="property"> = 3</em><a class="headerlink" href="#pymongo.collation.CollationStrength.TERTIARY" title="Permalink to this definition">¶</a></dt> <dd><p>Differentiate character case.</p> </dd></dl> <dl class="attribute"> <dt id="pymongo.collation.CollationStrength.QUATERNARY"> <code class="descname">QUATERNARY</code><em class="property"> = 4</em><a class="headerlink" href="#pymongo.collation.CollationStrength.QUATERNARY" title="Permalink to this definition">¶</a></dt> <dd><p>Differentiate words with and without punctuation.</p> </dd></dl> <dl class="attribute"> <dt id="pymongo.collation.CollationStrength.IDENTICAL"> <code class="descname">IDENTICAL</code><em class="property"> = 5</em><a class="headerlink" href="#pymongo.collation.CollationStrength.IDENTICAL" title="Permalink to this definition">¶</a></dt> <dd><p>Differentiate unicode code point (characters are exactly identical).</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="pymongo.collation.CollationAlternate"> <em class="property">class </em><code class="descclassname">pymongo.collation.</code><code class="descname">CollationAlternate</code><a class="headerlink" href="#pymongo.collation.CollationAlternate" title="Permalink to this definition">¶</a></dt> <dd><p>An enum that defines values for <cite>alternate</cite> on a <a class="reference internal" href="#pymongo.collation.Collation" title="pymongo.collation.Collation"><code class="xref py py-class docutils literal notranslate"><span class="pre">Collation</span></code></a>.</p> <dl class="attribute"> <dt id="pymongo.collation.CollationAlternate.NON_IGNORABLE"> <code class="descname">NON_IGNORABLE</code><em class="property"> = 'non-ignorable'</em><a class="headerlink" href="#pymongo.collation.CollationAlternate.NON_IGNORABLE" title="Permalink to this definition">¶</a></dt> <dd><p>Spaces and punctuation are treated as base characters.</p> </dd></dl> <dl class="attribute"> <dt id="pymongo.collation.CollationAlternate.SHIFTED"> <code class="descname">SHIFTED</code><em class="property"> = 'shifted'</em><a class="headerlink" href="#pymongo.collation.CollationAlternate.SHIFTED" title="Permalink to this definition">¶</a></dt> <dd><p>Spaces and punctuation are <em>not</em> considered base characters.</p> <p>Spaces and punctuation are distinguished regardless when the <a class="reference internal" href="#pymongo.collation.Collation" title="pymongo.collation.Collation"><code class="xref py py-class docutils literal notranslate"><span class="pre">Collation</span></code></a> strength is at least <a class="reference internal" href="#pymongo.collation.CollationStrength.QUATERNARY" title="pymongo.collation.CollationStrength.QUATERNARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">QUATERNARY</span></code></a>.</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="pymongo.collation.CollationCaseFirst"> <em class="property">class </em><code class="descclassname">pymongo.collation.</code><code class="descname">CollationCaseFirst</code><a class="headerlink" href="#pymongo.collation.CollationCaseFirst" title="Permalink to this definition">¶</a></dt> <dd><p>An enum that defines values for <cite>case_first</cite> on a <a class="reference internal" href="#pymongo.collation.Collation" title="pymongo.collation.Collation"><code class="xref py py-class docutils literal notranslate"><span class="pre">Collation</span></code></a>.</p> <dl class="attribute"> <dt id="pymongo.collation.CollationCaseFirst.UPPER"> <code class="descname">UPPER</code><em class="property"> = 'upper'</em><a class="headerlink" href="#pymongo.collation.CollationCaseFirst.UPPER" title="Permalink to this definition">¶</a></dt> <dd><p>Sort uppercase characters first.</p> </dd></dl> <dl class="attribute"> <dt id="pymongo.collation.CollationCaseFirst.LOWER"> <code class="descname">LOWER</code><em class="property"> = 'lower'</em><a class="headerlink" href="#pymongo.collation.CollationCaseFirst.LOWER" title="Permalink to this definition">¶</a></dt> <dd><p>Sort lowercase characters first.</p> </dd></dl> <dl class="attribute"> <dt id="pymongo.collation.CollationCaseFirst.OFF"> <code class="descname">OFF</code><em class="property"> = 'off'</em><a class="headerlink" href="#pymongo.collation.CollationCaseFirst.OFF" title="Permalink to this definition">¶</a></dt> <dd><p>Default for locale or collation strength.</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="pymongo.collation.CollationMaxVariable"> <em class="property">class </em><code class="descclassname">pymongo.collation.</code><code class="descname">CollationMaxVariable</code><a class="headerlink" href="#pymongo.collation.CollationMaxVariable" title="Permalink to this definition">¶</a></dt> <dd><p>An enum that defines values for <cite>max_variable</cite> on a <a class="reference internal" href="#pymongo.collation.Collation" title="pymongo.collation.Collation"><code class="xref py py-class docutils literal notranslate"><span class="pre">Collation</span></code></a>.</p> <dl class="attribute"> <dt id="pymongo.collation.CollationMaxVariable.PUNCT"> <code class="descname">PUNCT</code><em class="property"> = 'punct'</em><a class="headerlink" href="#pymongo.collation.CollationMaxVariable.PUNCT" title="Permalink to this definition">¶</a></dt> <dd><p>Both punctuation and spaces are ignored.</p> </dd></dl> <dl class="attribute"> <dt id="pymongo.collation.CollationMaxVariable.SPACE"> <code class="descname">SPACE</code><em class="property"> = 'space'</em><a class="headerlink" href="#pymongo.collation.CollationMaxVariable.SPACE" title="Permalink to this definition">¶</a></dt> <dd><p>Spaces alone are ignored.</p> </dd></dl> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="client_session.html" title="previous chapter"><code class="docutils literal notranslate"><span class="pre">client_session</span></code> – Logical sessions for sequential operations</a></p> <h4>Next topic</h4> <p class="topless"><a href="collection.html" title="next chapter"><code class="docutils literal notranslate"><span class="pre">collection</span></code> – Collection level operations</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/api/pymongo/collation.rst.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="collection.html" title="collection – Collection level operations" >next</a> |</li> <li class="right" > <a href="client_session.html" title="client_session – Logical sessions for sequential operations" >previous</a> |</li> <li class="nav-item nav-item-0"><a href="../../index.html">PyMongo 3.7.2 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="../index.html" >API Documentation</a> »</li> <li class="nav-item nav-item-2"><a href="index.html" ><code class="docutils literal notranslate"><span class="pre">pymongo</span></code> – Python driver for MongoDB</a> »</li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright MongoDB, Inc. 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc. </div> </body> </html>