-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add cn doc (#708) * add cn doc * concat and show meta leader * Update 13.concat.md Co-authored-by: 朱晓青 <[email protected]> * ldap and improve query by tag index (#711) * ldap and improve query by tag index * Update improve-query-by-tag-index.md * Update 4.ldap.md Co-authored-by: cooper-lzy <[email protected]>
- Loading branch information
1 parent
04a00f5
commit 32e456c
Showing
5 changed files
with
296 additions
and
1 deletion.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# concat function | ||
|
||
The `concat()` and `concat_ws()` functions return strings concatenated by one or more strings. | ||
|
||
## concat() function | ||
|
||
The `concat()` function requires at least two or more strings. All the parameters are concatenated into one string. | ||
|
||
- If there is only one string, the string itself is returned. | ||
|
||
- If any one of the strings is `NULL`, `NULL` is returned. | ||
|
||
### Syntax | ||
|
||
```bash | ||
concat(string1,string2,...) | ||
``` | ||
|
||
### Examples | ||
|
||
```bash | ||
//This example concatenates 1, 2, and 3. | ||
nebula> RETURN concat("1","2","3") AS r; | ||
+-------+ | ||
| r | | ||
+-------+ | ||
| "123" | | ||
+-------+ | ||
|
||
//In this example, one of the string is NULL. | ||
nebula> RETURN concat("1","2",NULL) AS r; | ||
+----------+ | ||
| r | | ||
+----------+ | ||
| __NULL__ | | ||
+----------+ | ||
|
||
nebula> GO FROM "player100" over follow \ | ||
YIELD concat(follow._src, $^.player.age, $$.player.name, follow.degree) AS A; | ||
+------------------------------+ | ||
| A | | ||
+------------------------------+ | ||
| "player10042Tony Parker95" | | ||
+------------------------------+ | ||
| "player10042Manu Ginobili95" | | ||
+------------------------------+ | ||
``` | ||
|
||
## concat_ws() function | ||
|
||
The `concat_ws()` function connects two or more strings with a predefined separator. | ||
|
||
- If the separator is `NULL`, the `concat_ws()` function returns `NULL`. | ||
|
||
- If the separator is not `NULL` and there is only one string, the string itself is returned. | ||
|
||
- If the separator is not `NULL` and there is a `NULL` in the strings, `NULL` is ignored during the concatenation. | ||
|
||
### Syntax | ||
|
||
```bash | ||
concat_ws(separator,string1,string2,... ) | ||
``` | ||
|
||
### Examples | ||
|
||
```bash | ||
//This example concatenates a, b, and c with the separator +. | ||
nebula> RETURN concat_ws("+","a","b","c") AS r; | ||
+---------+ | ||
| r | | ||
+---------+ | ||
| "a+b+c" | | ||
+---------+ | ||
|
||
//In this example, the separator is NULL. | ||
neubla> RETURN concat_ws(NULL,"a","b","c") AS r; | ||
+----------+ | ||
| r | | ||
+----------+ | ||
| __NULL__ | | ||
+----------+ | ||
|
||
//In this example, the separator is + and there is a NULL in the strings. | ||
nebula> RETURN concat_ws("+","a",NULL,"b","c") AS r; | ||
+---------+ | ||
| r | | ||
+---------+ | ||
| "a+b+c" | | ||
+---------+ | ||
|
||
//In this example, the separator is + and there is only one string. | ||
nebula> RETURN concat_ws("+","a") AS r; | ||
+-----+ | ||
| r | | ||
+-----+ | ||
| "a" | | ||
+-----+ | ||
|
||
nebula> GO FROM "player100" over follow \ | ||
YIELD concat_ws(" ",follow._src, $^.player.age, $$.player.name, follow.degree) AS A; | ||
+---------------------------------+ | ||
| A | | ||
+---------------------------------+ | ||
| "player100 42 Tony Parker 95" | | ||
+---------------------------------+ | ||
| "player100 42 Manu Ginobili 95" | | ||
+---------------------------------+ | ||
``` |
27 changes: 27 additions & 0 deletions
27
docs-2.0/3.ngql-guide/7.general-query-statements/6.show/19.show-meta-leader.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SHOW META LEADER | ||
|
||
The `SHOW META LEADER` statement shows the information of the leader in the current Meta cluster. | ||
|
||
For more information about the Meta service, see [Meta service](../../../1.introduction/3.nebula-graph-architecture/2.meta-service.md). | ||
|
||
## Syntax | ||
|
||
```ngql | ||
SHOW META LEADER; | ||
``` | ||
|
||
## Example | ||
|
||
```ngql | ||
nebula> SHOW META LEADER; | ||
+------------------+---------------------------+ | ||
| Meta Leader | secs from last heart beat | | ||
+------------------+---------------------------+ | ||
| "127.0.0.1:9559" | 3 | | ||
+------------------+---------------------------+ | ||
``` | ||
|
||
|Parameter|Description| | ||
|:---|:---| | ||
|`Meta Leader`|Shows the information of the leader in the Meta cluster, including the IP address and port of the server where the leader is located.| | ||
|`secs from last heart beat`|Indicates the time interval since the last heartbeat. This parameter is measured in seconds.| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# OpenLDAP authentication | ||
|
||
This topic introduces how to connect Nebula Graph to the OpenLDAP server and use the DN (Distinguished Name) and password defined in OpenLDAP for authentication. | ||
|
||
!!! enterpriseonly | ||
|
||
This feature is supported by the Enterprise Edition only. | ||
|
||
## Authentication method | ||
|
||
After the OpenLDAP authentication is enabled and users log into Nebula Graph with the account and password, Nebula Graph checks whether the login account exists in the Meta service. If the account exists, Nebula Graph finds the corresponding DN in OpenLDAP according to the authentication method and verifies the password. | ||
|
||
OpenLDAP supports two authentication methods: simple bind authentication (SimpleBindAuth) and search bind authentication (SearchBindAuth). | ||
|
||
### SimpleBindAuth | ||
|
||
Simple bind authentication splices the login account and the configuration information of Graph services into a DN that can be recognized by OpenLDAP, and then authenticates on OpenLDAP based on the DN and password. | ||
|
||
### SearchBindAuth | ||
|
||
Search bind authentication reads the Graph service configuration information and queries whether the `uid` in the configuration matches the login account. If they match, search bind authentication reads the DN, and then uses the DN and password to verify on OpenLDAP. | ||
|
||
## Prerequisites | ||
|
||
- [OpenLDAP](https://www.openldap.org/) is installed. | ||
|
||
- The account and password are imported on OpenLDAP. | ||
|
||
- The server where OpenLDAP is located has opened the corresponding authentication port. | ||
|
||
## Procedures | ||
|
||
Take the existing account `test2` and password `passwdtest2` on OpenLDAP as an example. | ||
|
||
1. [Connect to Nebula Graph](../../4.deployment-and-installation/connect-to-nebula-graph.md), create and authorize the shadow account `test2` corresponding to OpenLDAP. | ||
|
||
```ngql | ||
nebula> CREATE USER test2 WITH PASSWORD ''; | ||
nebula> GRANT ROLE ADMIN ON basketballplayer TO test2; | ||
``` | ||
|
||
!!! note | ||
|
||
When creating an account in Nebula Graph, the password can be set arbitrarily. | ||
|
||
2. Edit the configuration file `nebula-graphd.conf` (The default path is`/usr/local/nebula/etc/`): | ||
|
||
- SimpleBindAuth (Recommended) | ||
|
||
```bash | ||
# Whether to get the configuration information from the configuration file. | ||
--local_config=true | ||
# Whether to enable authentication. | ||
--enable_authorize=true | ||
# Authentication methods include password, ldap, and cloud. | ||
--auth_type=ldap | ||
# The address of the OpenLDAP server. | ||
--ldap_server=192.168.8.211 | ||
# The port of the OpenLDAP server. | ||
--ldap_port=389 | ||
# The name of the Schema in OpenLDAP. | ||
--ldap_scheme=ldap | ||
# The prefix of DN. | ||
--ldap_prefix=uid= | ||
# The suffix of DN. | ||
--ldap_suffix=,ou=it,dc=sys,dc=com | ||
``` | ||
|
||
- SearchBindAuth | ||
|
||
```bash | ||
# Whether to get the configuration information from the configuration file. | ||
--local_config=true | ||
# Whether to enable authentication. | ||
--enable_authorize=true | ||
# Authentication methods include password, ldap, and cloud. | ||
--auth_type=ldap | ||
# The address of the OpenLDAP server. | ||
--ldap_server=192.168.8.211 | ||
# The port of the OpenLDAP server. | ||
--ldap_port=389 | ||
# The name of the Schema in OpenLDAP. | ||
--ldap_scheme=ldap | ||
# The DN that binds the target. | ||
--ldap_basedn=uid=test2,ou=it,dc=sys,dc=com | ||
``` | ||
|
||
3. [Restart Nebula Graph services](../../4.deployment-and-installation/manage-service.md) to make the new configuration valid. | ||
|
||
4. Run the login test. | ||
|
||
```bash | ||
$ ./nebula-console --addr 127.0.0.1 --port 9669 -u test2 -p passwdtest2 | ||
2021/09/08 03:49:39 [INFO] connection pool is initialized successfully | ||
Welcome to Nebula Graph! | ||
``` | ||
|
||
!!! note | ||
|
||
After using OpenLDAP for authentication, local users (including `root`) cannot log in normally. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Add and delete tags | ||
|
||
OpenCypher has the features of `SET label` and `REMOVE label` to speed up the process of querying or labeling. | ||
|
||
Nebula Graph achieves the same operations by creating and inserting tags to an existing vertex, which can quickly query vertices based on the tag name. Users can also run `DELETE TAG` to delete some vertices that are no longer needed. | ||
|
||
!!! caution | ||
|
||
Make sure that there is another tag on the vertex. Otherwise, the vertex will be deleted when the last tag is deleted. | ||
|
||
## Examples | ||
|
||
For example, in the `basketballplayer` data set, some basketball players are also team shareholders. Users can create an index for the shareholder tag `shareholder` for quick search. If the player is no longer a shareholder, users can delete the shareholder tag of the corresponding player by `DELETE TAG`. | ||
|
||
```ngql | ||
//This example creates the shareholder tag and index. | ||
nebula> CREATE TAG shareholder(); | ||
nebula> CREATE TAG INDEX shareholder_tag on shareholder(); | ||
//This example adds a tag on the vertex. | ||
nebula> INSERT VERTEX shareholder() VALUES "player100":(); | ||
nebula> INSERT VERTEX shareholder() VALUES "player101":(); | ||
//This example queries all the shareholders. | ||
nebula> MATCH (v:shareholder) RETURN v; | ||
+---------------------------------------------------------------------+ | ||
| v | | ||
+---------------------------------------------------------------------+ | ||
| ("player100" :player{age: 42, name: "Tim Duncan"} :shareholder{}) | | ||
+---------------------------------------------------------------------+ | ||
| ("player101" :player{age: 36, name: "Tony Parker"} :shareholder{}) | | ||
+---------------------------------------------------------------------+ | ||
nebula> LOOKUP ON shareholder; | ||
+-------------+ | ||
| VertexID | | ||
+-------------+ | ||
| "player100" | | ||
+-------------+ | ||
| "player101" | | ||
+-------------+ | ||
//In this example, the "player100" is no longer a shareholder. | ||
nebula> DELETE TAG shareholder FROM "player100"; | ||
nebula> LOOKUP ON shareholder; | ||
+-------------+ | ||
| VertexID | | ||
+-------------+ | ||
| "player101" | | ||
+-------------+ | ||
``` | ||
|
||
!!! note | ||
|
||
If the index is created after inserting the test data, use the `REBUILD TAG INDEX <index_name_list>;` statement to rebuild the index. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters