GMishx opened a new issue, #4997:
URL: https://github.com/apache/couchdb/issues/4997
## Description
I have compiled latest couchdb with `./configure --enable-nouveau` and it is
running fine. Even started the nouveau server with the created
`./rel/couchdb/nouveau/bin/nouveau server`.
Now, when I try to query the information from the indexes, it does not work
for fields other than for `email`.
## Steps to Reproduce
I have a `sw360users` database with following fields:
```json
{
"_id": "2b1086cef0a14b7eaeb6f0204b58b8cf",
"_rev": "1-bb5f36a88a804eeba165b704090476b7",
"type": "user",
"email": "[email protected]",
"userGroup": "CLEARING_ADMIN",
"fullname": "Test Clearing1",
"givenname": "Test",
"lastname": "Clearing1"
}
```
Upon this DB, created a ddoc for nouveau with following document:
```json
{
"_id": "_design/nouveau_user",
"nouveau": {
"users": {
"index": "function(doc) {\n if (doc.type == 'user' ) {\n if
(typeof(doc.givenname) == 'string') {\n index(\"string\", \"givenname\",
doc.givenname, {\"store\": true});\n }\n if (typeof(doc.email) ==
'string') {\n index(\"string\", \"email\", doc.email, {\"store\":
true});\n }\n if (typeof(doc.lastname) == 'string') {\n
index(\"string\", \"lastname\", doc.lastname, {\"store\": true});\n }\n
}\n}",
"default_analyzer": "english",
"field_analyzers": {
"email": "email"
}
}
}
}
```
Here, I am indexing 3 fields, `givenname`, `lastname` and `email`. I tried
various configurations by changing the positions of `index()` in the function,
using different type of analyzers for creating the index.
I see no error in the nouveau logs or in the couchdb logs after the creation
of ddoc. Thus, I relaxed :-)
__Note:__ Responses are trimmed for brevity.
Now, when I queried all records with `q=*:*`, I get 10 fields since I have
10 users:
`$ curl --user "admin:admin"
'http://localhost:5984/sw360users/_design/nouveau_user/_nouveau/users' -X POST
-H 'Content-Type: application/json' -d '{"q": "*:*"}'`
```json
{"total_hits_relation":"EQUAL_TO","total_hits":10,"ranges":null,"hits":[{"order":[{"value":1.0,"@type":"float"},{"value":"11a7c29def2c4304a97db812521bd82c","@type":"string"}],"id":"11a7c29def2c4304a97db812521bd82c","fields":{"lastname":"Administrator","givenname":"Setup","email":"[email protected]"}},{"order":[{"value":1.0,"@type":"float"},{"value":"2a7cedcf38e24ebbade7a23f3f07f793","@type":"string"}],"id":"2a7cedcf38e24ebbade7a23f3f07f793","fields":{"lastname":"Clearing2","givenname":"Test","email":"[email protected]"}}],"counts":null,"bookmark":"W1t7InZhbHVlIjoxLjAsIkB0eXBlIjoiZmxvYXQifSx7InZhbHVlIjoiZWIzM2U2ZGI1YTE1NDAxNjgxMDg4OWQ4ZTU0NWZmODIiLCJAdHlwZSI6InN0cmluZyJ9XSxbeyJ2YWx1ZSI6MS4wLCJAdHlwZSI6ImZsb2F0In0seyJ2YWx1ZSI6ImVmMjMxYjQ5NTk3ZDRiZDViMmI4OThkNjcxODIwY2U3IiwiQHR5cGUiOiJzdHJpbmcifV1d"}
```
If I try to query with field `email`, I get expected response:
`$ curl --user "admin:admin"
'http://localhost:5984/sw360users/_design/nouveau_user/_nouveau/users' -X POST
-H 'Content-Type: application/json' -d '{"q": "email:setup*"}'`
```json
{"total_hits_relation":"EQUAL_TO","total_hits":1,"ranges":null,"hits":[{"order":[{"value":1.0,"@type":"float"},{"value":"11a7c29def2c4304a97db812521bd82c","@type":"string"}],"id":"11a7c29def2c4304a97db812521bd82c","fields":{"lastname":"Administrator","givenname":"Setup","email":"[email protected]"}}],"counts":null,"bookmark":"W1t7InZhbHVlIjoxLjAsIkB0eXBlIjoiZmxvYXQifSx7InZhbHVlIjoiMTFhN2MyOWRlZjJjNDMwNGE5N2RiODEyNTIxYmQ4MmMiLCJAdHlwZSI6InN0cmluZyJ9XV0="}
```
But with field `lastname`, I get nothing:
`$ curl --user "admin:admin"
'http://localhost:5984/sw360users/_design/nouveau_user/_nouveau/users' -X POST
-H 'Content-Type: application/json' -d '{"q": "lastname:Administrator"}'`
```json
{"total_hits_relation":"EQUAL_TO","total_hits":0,"ranges":null,"hits":[],"counts":null,"bookmark":"W10="}
```
Tried multiple times with `lastname:admin*`, `lastname:administrator`,
`lastname:Administrator` but failed to get any response even with different
analyzers. The behavior is same for the other field `givename`. Querying only
works for email with different lucene syntax.
## Expected Behaviour
Expected to query the indexes on different fields as well.
## Your Environment
`$ curl --user "admin:admin" 'http://localhost:5984'`
```json
{"couchdb":"Welcome","version":"3.3.3-29db2df","git_sha":"29db2df","uuid":"8722f4f42d4f2d566be241e6035df095","features":["nouveau","access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The
Apache Software Foundation"}}
```
Nouveau is also configured in `default.ini` using default
`./rel/couchdb/etc/nouveau.yaml`:
```
[nouveau]
enable = true
url = http://127.0.0.1:5987
```
* CouchDB version used: `3.3.3-29db2df`
* Browser name and version: `curl 8.2.1 (x86_64-conda-linux-gnu)
libcurl/8.2.1 OpenSSL/3.0.10 zlib/1.2.13 libssh2/1.10.0 nghttp2/1.52.0`
* Operating system and version: `Ubuntu 22.04.4 LTS`
## Additional Context
Using `counts` to aggregate index values works just as expected.
`$ curl --user "admin:admin"
'http://localhost:5984/sw360users/_design/nouveau_user/_nouveau/users' -X POST
-H 'Content-Type: application/json' -d '{"q": "*:*", "counts": ["lastname"]}'`
```json
{"total_hits_relation":"EQUAL_TO","total_hits":10,"ranges":null,"hits":[{"order":[{"value":1.0,"@type":"float"},{"value":"11a7c29def2c4304a97db812521bd82c","@type":"string"}],"id":"11a7c29def2c4304a97db812521bd82c","fields":{"lastname":"Administrator","givenname":"Setup","email":"[email protected]"}},{"order":[{"value":1.0,"@type":"float"},{"value":"2a7cedcf38e24ebbade7a23f3f07f793","@type":"string"}],"id":"2a7cedcf38e24ebbade7a23f3f07f793","fields":{"lastname":"Clearing2","givenname":"Test","email":"[email protected]"}}],"counts":{"lastname":{"User2":1,"User1":1,"User":1,"Clearing2":1,"Clearing1":1,"Clearing":1,"Administrator":1,"Admin2":1,"Admin1":1,"Admin":1}},"bookmark":"W1t7InZhbHVlIjoxLjAsIkB0eXBlIjoiZmxvYXQifSx7InZhbHVlIjoiZWIzM2U2ZGI1YTE1NDAxNjgxMDg4OWQ4ZTU0NWZmODIiLCJAdHlwZSI6InN0cmluZyJ9XSxbeyJ2YWx1ZSI6MS4wLCJAdHlwZSI6ImZsb2F0In0seyJ2YWx1ZSI6ImVmMjMxYjQ5NTk3ZDRiZDViMmI4OThkNjcxODIwY2U3IiwiQHR5cGUiOiJzdHJpbmcifV1d"}
```
--
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]