Skip to content

Commit 46441b9

Browse files
authored
Merge pull request #434 from ch2ohch2oh/enhance-select-wt
Set wt=json in _select only if the user has not set it
2 parents bfa70fa + d83aa60 commit 46441b9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pysolr.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ def _select(self, params, handler=None):
464464
:param handler: defaults to self.search_handler (fallback to 'select')
465465
:return:
466466
"""
467-
# specify json encoding of results
468-
params["wt"] = "json"
467+
# Returns json docs unless otherwise specified
468+
params.setdefault("wt", "json")
469469
custom_handler = handler or self.search_handler
470470
handler = "select"
471471
if custom_handler:

tests/test_client.py

+5
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ def test__select(self):
366366
self.assertEqual(len(resp_data["response"]["docs"]), 2)
367367
self.assertIn("nextCursorMark", resp_data)
368368

369+
def test__select_wt_xml(self):
370+
resp_body = self.solr._select({"q": "doc", "wt": "xml"})
371+
response = ElementTree.fromstring(resp_body)
372+
self.assertEqual(int(response.find("result").get("numFound")), 3)
373+
369374
def test__mlt(self):
370375
resp_body = self.solr._mlt({"q": "id:doc_1", "mlt.fl": "title"})
371376
resp_data = json.loads(resp_body)

0 commit comments

Comments
 (0)