Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Commit

Permalink
Merge pull request #27 from tobigue/feature/realtime_get
Browse files Browse the repository at this point in the history
Adds support for Solr's realtime /get handler.
  • Loading branch information
truemped committed Jul 7, 2014
2 parents a7a5a00 + 7998831 commit beb8225
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion dopplr/solr/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from tornado.httputil import HTTPHeaders
from tornado.ioloop import IOLoop

from .querybuilder import QueryBuilder


__all__ = ['SolrClient']

Expand Down Expand Up @@ -124,7 +126,7 @@ class SolrClient(object):

def __init__(self, search_host, update_host=None, default_headers=None,
required_query_params=[], client_args={}, select_path='/select',
update_path='/update/json', mlt_path='/mlt',
update_path='/update/json', mlt_path='/mlt', get_path='/get',
suggest_path='/suggest', document_verifier=None, ioloop=None):
"""
Initialize me.
Expand All @@ -133,6 +135,7 @@ def __init__(self, search_host, update_host=None, default_headers=None,

self._search_url = '%s%s' % (search_host, select_path)
self._mlt_url = '%s%s' % (search_host, mlt_path)
self._get_url = '%s%s' % (search_host, get_path)
self._termsuggest_url = '%s%s' % (search_host, suggest_path)
uhost = update_host or search_host
self._update_url = '%s%s' % (uhost, update_path)
Expand Down Expand Up @@ -248,6 +251,22 @@ def term_suggest(self, querybuilder, callback=None):
self._get(final_url, headers=querybuilder.headers,
callback=handle_suggest_response(querybuilder, callback))

def get_ids(self, ids, fields=None, response_mapper=None, callback=None):
"""
Using the Solr 4.X realtime /get handler:
https://wiki.apache.org/solr/RealTimeGet
"""
log.debug('realtime get with ids: %s' % ids)
params = [('ids', ','.join(map(unicode, ids)))]
if fields:
params.append(('fl', ','.join(fields)))
qs = urllib.urlencode(params)
final_url = '?'.join([self._get_url, qs])
log.debug('Final get URL: %s' % final_url)
qb = QueryBuilder(response_mapper=(response_mapper or (lambda x: x)))

self._get(final_url, callback=handle_search_response(qb, callback))

def index_document(self, doc, callback=None, commit=False,
commitWithin=None, softCommit=None, overwrite=None,
boost=None):
Expand Down

0 comments on commit beb8225

Please sign in to comment.