Similar to SQL LIKE statement in Couchbase

后端 未结 2 713
离开以前
离开以前 2021-01-23 17:16

Is this possible in Couchbase??

SELECT * FROM users WHERE user_name LIKE \'%john%\'.

Seems like I have to use startkey and endkey. But doesn\'t

相关标签:
2条回答
  • 2021-01-23 17:59

    The startKey and endKey will allow you to do like "john%". Couchbase does not allow you to do a contains.

    If you really need a contains you should use the Elastic Search plugin.

    0 讨论(0)
  • 2021-01-23 18:17

    Couchbase 4.5+ only


    Is needed to create a Full Text Index to be able search for substrings.

    1. Log in to the Couchbase Web Console, for example, http://localhost:8091/.
    2. Click Indexes > Full Text, then click on the New Full Text Index button.
    3. A form where you can define your new index configuration is displayed.
    4. Each index needs a unique name. Type one in, such as"test-index". Only alphanumeric characters, hyphens, and underscores are allowed for index names. Also, the first character must be an alphabetic character. Choose a bucket from the drop-down list. There are more options, but you can ignore those for now and rely on the default values. Go! Finally, click the Create Index button.
    5. You should now see a summary page of your new full text index. The document count shows how many documents have been indexed so far. You can click on the Refresh button next to the Document Count field in order to see the indexing progress.

    See Couchbase reference for more information


    NOTE: If you don't see Full text tab, you have to enable it and setup Full Text Search service (Full Text RAM Quota).

    0 讨论(0)
提交回复
热议问题