PageRenderTime 42ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/api/openlibrary/utils/solr.html

https://github.com/strogo/openlibrary.github.com
HTML | 165 lines | 153 code | 12 blank | 0 comment | 0 complexity | 882ee263e5136c69c68e611573a66029 MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>solr &mdash; openlibrary v2.0 documentation</title>
  7. <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
  8. <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '../../../',
  12. VERSION: '2.0',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="../../../_static/jquery.js"></script>
  19. <script type="text/javascript" src="../../../_static/underscore.js"></script>
  20. <script type="text/javascript" src="../../../_static/doctools.js"></script>
  21. <link rel="top" title="openlibrary v2.0 documentation" href="../../../index.html" />
  22. <link rel="up" title="utils" href="index.html" />
  23. <link rel="next" title="infogami" href="../../infogami/index.html" />
  24. <link rel="prev" title="schema" href="schema.html" />
  25. </head>
  26. <body>
  27. <div class="related">
  28. <h3>Navigation</h3>
  29. <ul>
  30. <li class="right" style="margin-right: 10px">
  31. <a href="../../../genindex.html" title="General Index"
  32. accesskey="I">index</a></li>
  33. <li class="right" >
  34. <a href="../../../py-modindex.html" title="Python Module Index"
  35. >modules</a> |</li>
  36. <li class="right" >
  37. <a href="../../infogami/index.html" title="infogami"
  38. accesskey="N">next</a> |</li>
  39. <li class="right" >
  40. <a href="schema.html" title="schema"
  41. accesskey="P">previous</a> |</li>
  42. <li><a href="../../../index.html">openlibrary v2.0 documentation</a> &raquo;</li>
  43. <li><a href="../../index.html" >API Documentation</a> &raquo;</li>
  44. <li><a href="../index.html" >openlibrary</a> &raquo;</li>
  45. <li><a href="index.html" accesskey="U">utils</a> &raquo;</li>
  46. </ul>
  47. </div>
  48. <div class="document">
  49. <div class="documentwrapper">
  50. <div class="bodywrapper">
  51. <div class="body">
  52. <div class="section" id="module-openlibrary.utils.solr">
  53. <span id="solr"></span><h1>solr<a class="headerlink" href="#module-openlibrary.utils.solr" title="Permalink to this headline"></a></h1>
  54. <p>Python library for accessing Solr.</p>
  55. <dl class="class">
  56. <dt id="openlibrary.utils.solr.Solr">
  57. <em class="property">class </em><tt class="descclassname">openlibrary.utils.solr.</tt><tt class="descname">Solr</tt><big>(</big><em>base_url</em><big>)</big><a class="headerlink" href="#openlibrary.utils.solr.Solr" title="Permalink to this definition"></a></dt>
  58. <dd><dl class="method">
  59. <dt id="openlibrary.utils.solr.Solr.escape">
  60. <tt class="descname">escape</tt><big>(</big><em>query</em><big>)</big><a class="headerlink" href="#openlibrary.utils.solr.Solr.escape" title="Permalink to this definition"></a></dt>
  61. <dd><p>Escape special characters in the query string</p>
  62. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">solr</span> <span class="o">=</span> <span class="n">Solr</span><span class="p">(</span><span class="s">&quot;&quot;</span><span class="p">)</span>
  63. <span class="gp">&gt;&gt;&gt; </span><span class="n">solr</span><span class="o">.</span><span class="n">escape</span><span class="p">(</span><span class="s">&quot;a[b]c&quot;</span><span class="p">)</span>
  64. <span class="go">&#39;a\\[b\\]c&#39;</span>
  65. </pre></div>
  66. </div>
  67. </dd></dl>
  68. <dl class="method">
  69. <dt id="openlibrary.utils.solr.Solr.select">
  70. <tt class="descname">select</tt><big>(</big><em>query</em>, <em>fields=None</em>, <em>facets=None</em>, <em>rows=None</em>, <em>start=None</em>, <em>doc_wrapper=None</em>, <em>facet_wrapper=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#openlibrary.utils.solr.Solr.select" title="Permalink to this definition"></a></dt>
  71. <dd><p>Execute a solr query.</p>
  72. <p>query can be a string or a dicitonary. If query is a dictionary, query
  73. is constucted by concatinating all the key-value pairs with AND condition.</p>
  74. </dd></dl>
  75. </dd></dl>
  76. <dl class="function">
  77. <dt id="openlibrary.utils.solr.urlencode">
  78. <tt class="descclassname">openlibrary.utils.solr.</tt><tt class="descname">urlencode</tt><big>(</big><em>d</em>, <em>doseq=False</em><big>)</big><a class="headerlink" href="#openlibrary.utils.solr.urlencode" title="Permalink to this definition"></a></dt>
  79. <dd><p>There is a bug in urllib when used with unicode data.</p>
  80. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="p">{</span><span class="s">&quot;q&quot;</span><span class="p">:</span> <span class="s">u&quot;</span><span class="se">\u0C05</span><span class="s">&quot;</span><span class="p">}</span>
  81. <span class="gp">&gt;&gt;&gt; </span><span class="n">urllib</span><span class="o">.</span><span class="n">urlencode</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
  82. <span class="go">&#39;q=%E0%B0%85&#39;</span>
  83. <span class="gp">&gt;&gt;&gt; </span><span class="n">urllib</span><span class="o">.</span><span class="n">urlencode</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="n">doseq</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
  84. <span class="go">&#39;q=%3F&#39;</span>
  85. </pre></div>
  86. </div>
  87. <p>This function encodes all the unicode strings in utf-8 before passing them to urllib.</p>
  88. </dd></dl>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="sphinxsidebar">
  94. <div class="sphinxsidebarwrapper">
  95. <p class="logo"><a href="../../../index.html">
  96. <img class="logo" src="../../../_static/logo_OL-lg.png" alt="Logo"/>
  97. </a></p>
  98. <h4>Previous topic</h4>
  99. <p class="topless"><a href="schema.html"
  100. title="previous chapter">schema</a></p>
  101. <h4>Next topic</h4>
  102. <p class="topless"><a href="../../infogami/index.html"
  103. title="next chapter">infogami</a></p>
  104. <h3>This Page</h3>
  105. <ul class="this-page-menu">
  106. <li><a href="../../../_sources/api/openlibrary/utils/solr.txt"
  107. rel="nofollow">Show Source</a></li>
  108. </ul>
  109. <div id="searchbox" style="display: none">
  110. <h3>Quick search</h3>
  111. <form class="search" action="../../../search.html" method="get">
  112. <input type="text" name="q" size="18" />
  113. <input type="submit" value="Go" />
  114. <input type="hidden" name="check_keywords" value="yes" />
  115. <input type="hidden" name="area" value="default" />
  116. </form>
  117. <p class="searchtip" style="font-size: 90%">
  118. Enter search terms or a module, class or function name.
  119. </p>
  120. </div>
  121. <script type="text/javascript">$('#searchbox').show(0);</script>
  122. </div>
  123. </div>
  124. <div class="clearer"></div>
  125. </div>
  126. <div class="related">
  127. <h3>Navigation</h3>
  128. <ul>
  129. <li class="right" style="margin-right: 10px">
  130. <a href="../../../genindex.html" title="General Index"
  131. >index</a></li>
  132. <li class="right" >
  133. <a href="../../../py-modindex.html" title="Python Module Index"
  134. >modules</a> |</li>
  135. <li class="right" >
  136. <a href="../../infogami/index.html" title="infogami"
  137. >next</a> |</li>
  138. <li class="right" >
  139. <a href="schema.html" title="schema"
  140. >previous</a> |</li>
  141. <li><a href="../../../index.html">openlibrary v2.0 documentation</a> &raquo;</li>
  142. <li><a href="../../index.html" >API Documentation</a> &raquo;</li>
  143. <li><a href="../index.html" >openlibrary</a> &raquo;</li>
  144. <li><a href="index.html" >utils</a> &raquo;</li>
  145. </ul>
  146. </div>
  147. <div class="footer">
  148. &copy; Copyright 2006-2011, Internet Archive.
  149. Last updated on Feb 27, 2011.
  150. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
  151. </div>
  152. </body>
  153. </html>