You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling Solr.add without boost with a commitWithin value should still result in commitWithin being used for the Solr update.
Actual behaviour
As of version 3.9.0, the commitWithin is sent to Solr if the XML API is used but not if the JSON API is used, which happens if the boost arg to add is not provided.
Steps to reproduce the behaviour
Run the following against master, which uses a mock to verify that commitWithin is included in the XML API request but not for the JSON API request:
fromunittest.mockimportpatch, MagicMockimportpysolrsolr=pysolr.Solr("http://pysolr.test/")
# `commitWithin` is not included for the JSON API:withpatch.object(solr, "get_session") asmock:
mock().post.return_value=MagicMock(status_code=200)
solr.add([{"id": "doc1", "foo": "bar"}], commitWithin="1000")
mock().post.assert_called_once_with(
'http://pysolr.test/update/',
data=b'[{"id": "doc1", "foo": "bar"}]',
headers={'Content-type': 'application/json; charset=utf-8'},
files=None,
timeout=60,
auth=None,
)
# `commitWithin` is included in the XML doc for the XML API:withpatch.object(solr, "get_session") asmock:
mock().post.return_value=MagicMock(status_code=200)
solr.add([{"id": "doc1", "foo": "bar"}], commitWithin="1000", boost={"foo": 2.0})
mock().post.assert_called_once_with(
'http://pysolr.test/update/',
data=b'<add commitWithin="1000"><doc><field name="id">doc1</field><field name="foo" boost="2.0">bar</field></doc></add>',
headers={'Content-type': 'text/xml; charset=utf-8'},
files=None,
timeout=60,
auth=None,
)
I made a start on an update that switches to including the commitWithin in the URL for both JSON and XML. This simplifies things compared to including it in the message body, because to do that for the JSON API, you'd have to switch from the structure that you're currently using (a list of docs) to a different structure (such as a dict), because the list of docs format doesn't seem to provide any way to specify commitWithin.
Expected behaviour
Calling
Solr.add
withoutboost
with acommitWithin
value should still result incommitWithin
being used for the Solr update.Actual behaviour
As of version 3.9.0, the
commitWithin
is sent to Solr if the XML API is used but not if the JSON API is used, which happens if theboost
arg toadd
is not provided.Steps to reproduce the behaviour
Run the following against master, which uses a mock to verify that
commitWithin
is included in the XML API request but not for the JSON API request:I made a start on an update that switches to including the
commitWithin
in the URL for both JSON and XML. This simplifies things compared to including it in the message body, because to do that for the JSON API, you'd have to switch from the structure that you're currently using (a list of docs) to a different structure (such as a dict), because the list of docs format doesn't seem to provide any way to specifycommitWithin
.See pull request: #421
Configuration
The text was updated successfully, but these errors were encountered: