cloudant / python-cloudant

A Python library for Cloudant and CouchDB
Apache License 2.0
163 stars 55 forks source link

sort changed sort_field for get_search_result() #370

Closed gurusrin closed 6 years ago

gurusrin commented 6 years ago

In the new version of the Cloudant, the sort parameter has been changed to sort_field for searching using design documents. Therefore, this needs to be updated in _common_util.py file accordingly, so that function get_search_result() is able to return the results properly.

Current function call: results = get_search_result(designDoc, indexName, sort = "myfield<number>")

Modification required as per new change:

results = get_search_result(designDoc, indexName, sort_field = "myfield<number>")

emlaver commented 6 years ago

@gurusrin I didn't find any reference about the change from sort to sort_field in the IBM Cloud documentation. Could you please share the link where you found this info?

gurusrin commented 6 years ago

@emlaver, My code was failing for get_search_result() giving an unknown error. While checking the problem using HTTP URLs, I traced out that the problem was due to query parameter sort. While searching the internet, I found a link (unfortunately, I forgot to bookmark that link) which suggested the use of sort_field. When I tried the same out in HTTP URL, it worked out well.

Even I found that this has not been documented properly and has been misleading.

emlaver commented 6 years ago

@gurusrin Could you please contact our support team via support@cloudant.com with your account name so we can further investigate? Thanks.

rnewson commented 6 years ago

I don't think this was changed. more likely you specified an invalid value to 'sort' and got an error. When you switched to 'sort_field', you didn't get an error because we don't examine unknown parameters, but you wouldn't get the right sort order either.

gurusrin commented 6 years ago

Sorry for the late response. I have raised the issue with the Cloudant Support team and awaiting their response.

gurusrin commented 6 years ago

Upon working with the Cloudant Support, I found that the mistake was at my end. I had been assuming the sort field to be integer but actually it appeared to be a string field. After making the appropriate changes, the results are coming fine.