Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To implement case insensitive search you just have to convert keys to lowercase: </p> <p><code>emit([doc.name.toLowerCase(), doc.cat.toLowerCase()])</code> </p> <p>Now, if you convert your query to lowercase you'll have case insensitive matching. The problem with this solution is that if you want both case sensitive and case insensitive search you can either emit both values:<br> <code>[doc.name.toLowerCase(), doc.name, doc.cat]</code><br> and use startkey and endkey to filter results, or create a separate view. </p> <hr> <p>The second question is a bit more tricky to implement.<br> First of all, if you need to filter by doc.name only you can send request with <code>startkey=["jack",0]</code> and <code>endkey=["jack",'zzzzzz']</code> which will return all documents with <code>doc.name="jack"</code> and <code>doc.cat</code> between <code>0</code> and <code>'zzzzzz'</code> (there probably is a better way to say "any cat", unfortunately I can't find it right now).<br> If you need a real OR, then you should emit two rows for each document:<br> <code>emit(doc.name, doc); emit(doc.cat, doc);</code> </p> <p>This way you can POST needed keys with your request: <code>{"keys": ["jack", "cat_name"]}</code><br> This will return every document with either <code>"jack"</code> OR <code>"cat_name"</code> key. However documents that have both will be returned twice, so you have to filter duplicates in your application code. </p> <hr> <p>You can also use <a href="https://github.com/rnewson/couchdb-lucene" rel="noreferrer">couchdb-lucene</a> which will solve both of your problems and probably a lot more. It is a popular choice among couchdb users for implementing advanced queries.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload