Created
October 7, 2010 16:21
-
-
Save lbjay/615383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:16) | |
Type "copyright", "credits" or "license" for more information. | |
IPython 0.10 -- An enhanced Interactive Python. | |
? -> Introduction and overview of IPython's features. | |
%quickref -> Quick reference. | |
help -> Python's own help system. | |
object? -> Details about 'object'. ?object also works, ?? prints more. | |
In [1]: import solr | |
In [2]: import pysolr | |
/usr/lib/python2.6/site-packages/httplib2/__init__.py:44: DeprecationWarning: the sha module is deprecated; use the hashlib module instead | |
import sha | |
In [3]: s = solr.SolrConnection('http://127.0.0.1:8983/solr') | |
In [4]: conn = pysolr.Solr('http://127.0.0.1:8983/solr/') | |
In [5]: doc = {'id': 'foo', 'inStock': True, 'cat': 'bar', 'cat': 'baz', 'manufacture_dt': '2006-02-13T15:26:37Z', 'features': 'blah bleh'} | |
In [6]: %timeit s.add(**doc) | |
10 loops, best of 3: 43.4 ms per loop | |
In [7]: %timeit conn.add([doc]) | |
10 loops, best of 3: 22.7 ms per loop | |
In [8]: %timeit s.query('*:*') | |
10 loops, best of 3: 52.2 ms per loop | |
In [9]: %timeit conn.search('*:*') | |
100 loops, best of 3: 3.06 ms per loop | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In [38]: solr_interface = sunburnt.SolrInterface("http://localhost:8983/solr", "/home/jluker/projects/solrtest/apache-solr-1.4.1/example/solr/conf/schema.xml")
In [39]: %timeit solr_interface.add([doc])10 loops, best of 3: 44.9 ms per loop
In [62]: %timeit solr_interface.search(q=':').result.numFound
100 loops, best of 3: 4.13 ms per loop