jkuester opened a new issue, #5453:
URL: https://github.com/apache/couchdb/issues/5453

   ## Description
   
   Reading the 
[docs](https://docs.couchdb.org/en/latest/api/ddoc/nouveau.html#get--db-_design-ddoc-_nouveau-index)
 for querying a Nouveau index it states that:
   
   > You can use a single string to sort by one field or an array of strings to 
sort by several fields in the same order as the array. 
   
   Unfortunately, when I try to use more than `3` fields in the `sort` array on 
a query request, an error occurs in my Couch instance.
   
   ## Steps to Reproduce
   
   I have created a design doc with a Nouveau index that has the following code:
   
   ```js
   function (doc) {
     var types = [ 'district_hospital', 'health_center', 'clinic', 'person' ];
     if (types.indexOf(doc.type) === -1) {
       return;
     }
   
     index('string', 'contact_type', doc.type);
     index('string', 'contact_type_index', String(types.indexOf(doc.type)));
     index('string', 'dead', String(!!doc.date_of_death));
     index('string', 'muted', String(!!doc.muted));
     var name = doc.name && typeof doc.name === 'string' ? 
doc.name.toLowerCase() : '';
     index('string', 'name', name);
   }
   ```
   
   Then, I am querying this index by POSTing the following body:
   
   ```json
   {
     "q":"*:*",
     "sort":[
       "dead",
       "muted",
       "contact_type_index",
       "name"
     ]
   }
   ```
   
   Unfortunately, the server responds with a `500` error and:
   
   ```json
   {
     "error": "unknown_error",
     "reason": "badarith",
     "ref": 3197294518
   }
   ```
   
   In the logs from my CouchDB instance I see:
   
   ```
   [notice] 2025-02-28T21:00:01.823920Z [email protected] <0.10807.50> 
87d80e15f1 localhost:5984 172.19.0.1 medic POST 
/medic/_design/medic/_nouveau/test_index 500 ok 9
   2025-02-28T21:00:15.086077441Z [error] 2025-02-28T21:00:15.085810Z 
[email protected] <0.10928.50> c47dc7a1e9 req_err(3197294518) unknown_error : 
badarith
   2025-02-28T21:00:15.086103849Z     
[<<"erlang:bsr/2">>,<<"base64:encode_list/2 
L94">>,<<"nouveau_httpd:handle_search_req/6 
L109">>,<<"nouveau_httpd:handle_search_req/3 
L57">>,<<"chttpd:handle_req_after_auth/2 L428">>,<<"chttpd:process_request/1 
L406">>,<<"chttpd:handle_request_int/1 L341">>,<<"mochiweb_http:headers/6 
L140">>]
   ```
   
   There are no errors in the Nouveau logs (only `200` successes).
   
   If I repeat the request with only 3 entries in the `sort` array, it succeeds 
(regardless of which field I remove from the array).
   
   ## Expected Behaviour
   
   I expect the `sort` array to be able to support a reasonable amount of sort 
parameters (>3) without erroring.
   
   ## Your Environment
   
   ```json
   {
     "couchdb": "Welcome",
     "version": "3.4.2",
     "git_sha": "6e5ad2a5c",
     "uuid": "326d5bb8-96c4-47d4-a5c0-bade13a2c24c",
     "features": [
       "nouveau",
       "access-ready",
       "partitioned",
       "pluggable-storage-engines",
       "reshard",
       "scheduler"
     ],
     "vendor": {
       "name": "The Apache Software Foundation"
     }
   }
   ```
   
   CouchDB Docker image built `FROM couchdb:3.4.2`
   Nouveau Docker image build `FROM couchdb:3.4.2-nouveau`
   
   ## Additional Context
   
   I am new to Nouveau indexes and have been trying to closely follow [the 
docs](https://docs.couchdb.org/en/latest/ddocs/nouveau.html#ddoc-nouveau), but 
perhaps I missed something and am actually trying to do something in an 
improper way....
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to