You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "gruberjl (via GitHub)" <gi...@apache.org> on 2023/10/05 20:40:47 UTC

[I] Pipe (|) character in find query isn't returning data [couchdb]

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

   ## Description
   
   My _id field contains two pieces of information separated by a | (pipe). Then I use the find to get all docs with SomeData|. I have the following mock data and selector:
   
   EXAMPLE DATA:
   ```
   {_id:"course|001"}
   {_id:"course|002"}
   {_id:"course2|001"}
   {_id:"course3|001"}
   ```
   
   SELECTOR:
   ```
   {
      "selector": {
         "_id": {
            "$gte": "course|",
            "$lt": "course}"
         }
      }
   }
   ```
   
   This should return all documents that start with course| but it doesn't return anything. If I remove the | then it will return all the documents but it may return too many documents.
   
   ## Steps to Reproduce
   
   Create the following docs
   ```
   {_id:"course|001"}
   {_id:"course|002"}
   {_id:"course2|001"}
   {_id:"course3|001"}
   ```
   
   Open the http://127.0.0.1:5984/_utils/#database/blog/_find query.
   
   Enter the following selector:
   ```
   {
      "selector": {
         "_id": {
            "$gte": "course|",
            "$lt": "course}"
         }
      }
   }
   ```
   
   Run the query
   
   ## Expected Behaviour
   
   It should return all documents that start with "course|"
   
   ## Your Environment
   
   {"couchdb":"Welcome","version":"3.2.2","git_sha":"d5b746b7c","uuid":"a92b7a861d1bb4a4a45843566ea53b9d","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
   
   * CouchDB version used: v. 3.2.2
   * Browser name and version: Chrome Version 117.0.5938.92 (Official Build) (64-bit)
   * Operating system and version: Windows 10 Version: 22H2 (19045.3324)
   


-- 
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: notifications-unsubscribe@couchdb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Pipe (|) character in find query isn't returning data [couchdb]

Posted by "gruberjl (via GitHub)" <gi...@apache.org>.
gruberjl commented on issue #4802:
URL: https://github.com/apache/couchdb/issues/4802#issuecomment-1749632649

   I didn't define any index.
   
   Nevermind. I think I figured it out. The correct approach Is:
   
   ```
   {
      "selector": {
         "_id": {
            "$gte": "course|",
            "$lt": "course|\ufff0"
         }
      }
   }
   ```


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Pipe (|) character in find query isn't returning data [couchdb]

Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on issue #4802:
URL: https://github.com/apache/couchdb/issues/4802#issuecomment-1749640843

    hm not sure about that. ```curl -g 'foo:bar@localhost:15984/db1/_all_docs?startkey="foo1|"&endkey="foo1}"'``` works just fine. the (more obscure) selector-based _find version should return the same results.


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Pipe (|) character in find query isn't returning data [couchdb]

Posted by "gruberjl (via GitHub)" <gi...@apache.org>.
gruberjl commented on issue #4802:
URL: https://github.com/apache/couchdb/issues/4802#issuecomment-1750686995

   I was using all docs but I had to switch because I need to filter on another field too.


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Pipe (|) character in find query isn't returning data [couchdb]

Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on issue #4802:
URL: https://github.com/apache/couchdb/issues/4802#issuecomment-1750975026

   we tracked this down. the way _id strings are sorted is different to how other indexed strings are sorted, which explains the difference.
   
   without an index the performance of `_find` can be quite poor, it is a database scan each time. I'd advise against relying on unindexed querying for anything important.


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Pipe (|) character in find query isn't returning data [couchdb]

Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on issue #4802:
URL: https://github.com/apache/couchdb/issues/4802#issuecomment-1749630756

   which kind of index did you define?


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Pipe (|) character in find query isn't returning data [couchdb]

Posted by "gruberjl (via GitHub)" <gi...@apache.org>.
gruberjl closed issue #4802: Pipe (|) character in find query isn't returning data
URL: https://github.com/apache/couchdb/issues/4802


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Pipe (|) character in find query isn't returning data [couchdb]

Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on issue #4802:
URL: https://github.com/apache/couchdb/issues/4802#issuecomment-1749652587

   check the `_explain` output to see if your `_find` request is as efficient as the direct `_all_docs` request above. specifically look at the `mrargs` section to see if startkey/endkey are sent. If not, couchdb is reading the entire db and then filtering afterward, which is much less efficient than `_all_docs?startkey="foo1|"&endkey="foo1}|`.


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org