Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set wt=json in _select only if the user has not set it #434

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pysolr.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ def _select(self, params, handler=None):
:param handler: defaults to self.search_handler (fallback to 'select')
:return:
"""
# specify json encoding of results
params["wt"] = "json"
# Returns json docs unless otherwise specified
params.setdefault("wt", "json")
custom_handler = handler or self.search_handler
handler = "select"
if custom_handler:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ def test__select(self):
self.assertEqual(len(resp_data["response"]["docs"]), 2)
self.assertIn("nextCursorMark", resp_data)

def test__select_wt_xml(self):
resp_body = self.solr._select({"q": "doc", "wt": "xml"})
response = ElementTree.fromstring(resp_body)
self.assertEqual(int(response.find("result").get("numFound")), 3)

def test__mlt(self):
resp_body = self.solr._mlt({"q": "id:doc_1", "mlt.fl": "title"})
resp_data = json.loads(resp_body)
Expand Down
Loading