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
import solrpy | |
conn = solrpy.SolrConnection('http://search.example.com/solr') |
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
conn.add(id=1, title="Lucene in Action", author=["Erik Hatcher", "Otis Gospodnetic"]) | |
docs = [] | |
docs.append({'id':1, 'title':"Lucene in Action", 'author':["Erik Hatcher", "Otis Gospodnetic"]}) | |
docs.append({'id':2, 'title':"Programming Collective Intelligence", 'author':"Toby Segaran"}) | |
conn.add(docs) |
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
import solrpy | |
conn = solrpy.SolrConnection('http://search.example.com/solr') | |
conn.add(id=1, title="Lucene in Action", author=["Erik Hatcher", "Otis Gospodnetić"]) | |
conn.commit() | |
response = conn.query("lucene") | |
for result in response.results: | |
print "%d - %s" % (result['id'], result['title']) |
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
doc = solrpy.Document(1.6) | |
# like a dictionary | |
doc['id'] = 1 | |
doc['title'] = solrpy.Field("Lucene in Action", boost=1.5) | |
doc['author'] = ["Erik Hatcher", solrpy.Field("Otis Gospodnetić", boost=1.1)] | |
# or with add() | |
doc.add(id=1, title=solrpy.Field("Lucene in Action", boost=1.5), author=["Erik Hatcher", solrpy.Field("Otis Gospodnetić", boost=1.1)]) |
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
conn.add(True, id=1, title="Lucene in Action") |
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
conn.delete(1) | |
conn.delete([2, 3]) | |
conn.commit() |
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
conn.delete_query('title:foo') | |
conn.delete_query(['title:foo', 'title:bar']) | |
conn.commit() |
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
results = conn.query('foo:bar') | |
print "Your query executed in %s microseconds" % results.header['QTime'] | |
for result in results.results: | |
print result['title'] |
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
import traceback | |
def app_view_processor(request): | |
"""Add the current application and view names to the context.""" | |
params = {} | |
for item in reversed(traceback.extract_stack()): | |
if item[0].endswith("/views.py"): | |
params['CURRENT_APP'] = item[0].split("/")[-2] | |
params['CURRENT_VIEW'] = item[2] | |
return params |
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
db.test.save({grouper:1, checker:false}); | |
db.test.save({grouper:1, checker:false}); | |
db.test.save({grouper:2, checker:false}); | |
db.test.save({grouper:2, checker:false}); | |
db.test.save({grouper:2, checker:false}); | |
db.test.save({grouper:2, checker:false}); | |
db.test.save({grouper:2, checker:false}); | |
db.test.save({grouper:1, checker:false}); | |
db.test.find({checker:false}).forEach(function(test) { | |
db.test.update({checker:test.checker}, {$set:{checker:true}}, false, true); |
OlderNewer