github.com/cayleygraph/cayley@v0.7.7/docs/advanced-use.md (about)

     1  # Advanced Use
     2  
     3  ## Initialize A Graph
     4  
     5  Now that Cayley is downloaded \(or built\), let's create our database. `init` is the subcommand to set up a database and the right indices.
     6  
     7  You can set up a full [configuration file](configuration.md) if you'd prefer, but it will also work from the command line.
     8  
     9  Examples for each backend can be found in `store.address` format from [config file](configuration.md).
    10  
    11  Those two options \(db and dbpath\) are always going to be present. If you feel like not repeating yourself, setting up a configuration file for your backend might be something to do now. There's an example file, `cayley_example.yml` in the root directory.
    12  
    13  You can repeat the `--db (-i)` and `--dbpath (-a)` flags from here forward instead of the config flag, but let's assume you created `cayley_overview.yml`
    14  
    15  Note: when you specify parameters in the config file the config flags \(command line arguments\) are ignored.
    16  
    17  ## Load Data Into A Graph
    18  
    19  After the database is initialized we load the data.
    20  
    21  ```bash
    22  ./cayley load -c cayley_overview.yml -i data/testdata.nq
    23  ```
    24  
    25  And wait. It will load. If you'd like to watch it load, you can run
    26  
    27  ```bash
    28  ./cayley load -c cayley_overview.yml -i data/testdata.nq --alsologtostderr=true
    29  ```
    30  
    31  And watch the log output go by.
    32  
    33  If you plan to import a large dataset into Cayley and try multiple backends, it makes sense to first convert the dataset to Cayley-specific binary format by running:
    34  
    35  ```bash
    36  ./cayley conv -i dataset.nq.gz -o dataset.pq.gz
    37  ```
    38  
    39  This will minimize parsing overhead on future imports and will compress dataset a bit better.
    40  
    41  ## Connect a REPL To Your Graph
    42  
    43  Now it's loaded. We can use Cayley now to connect to the graph. As you might have guessed, that command is:
    44  
    45  ```bash
    46  ./cayley repl -c cayley_overview.yml
    47  ```
    48  
    49  Where you'll be given a `cayley>` prompt. It's expecting Gizmo/JS, but that can also be configured with a flag.
    50  
    51  New nodes and links can be added with the following command:
    52  
    53  ```bash
    54  cayley> :a subject predicate object label .
    55  ```
    56  
    57  Removing links works similarly:
    58  
    59  ```bash
    60  cayley> :d subject predicate object .
    61  ```
    62  
    63  This is great for testing, and ultimately also for scripting, but the real workhorse is the next step.
    64  
    65  Go ahead and give it a try:
    66  
    67  ```text
    68  // Simple math
    69  cayley> 2 + 2
    70  
    71  // JavaScript syntax
    72  cayley> x = 2 * 8
    73  cayley> x
    74  
    75  // See all the entities in this small follow graph.
    76  cayley> graph.Vertex().All()
    77  
    78  // See only dani.
    79  cayley> graph.Vertex("<dani>").All()
    80  
    81  // See who dani follows.
    82  cayley> graph.Vertex("<dani>").Out("<follows>").All()
    83  ```
    84  
    85  ## Serve Your Graph
    86  
    87  Just as before:
    88  
    89  ```bash
    90  ./cayley http -c cayley_overview.yml
    91  ```
    92  
    93  And you'll see a message not unlike
    94  
    95  ```bash
    96  listening on :64210, web interface at http://localhost:64210
    97  ```
    98  
    99  If you visit that address \(often, [http://localhost:64210](http://localhost:64210)\) you'll see the full web interface and also have a graph ready to serve queries via the [HTTP API](http.md)
   100  
   101  ### Access from other machines
   102  
   103  When you want to reach the API or UI from another machine in the network you need to specify the host argument:
   104  
   105  ```bash
   106  ./cayley http --config=cayley.cfg.overview --host=0.0.0.0:64210
   107  ```
   108  
   109  This makes it listen on all interfaces. You can also give it the specific the IP address you want Cayley to bind to.
   110  
   111  **Warning**: for security reasons you might not want to do this on a public accessible machine.
   112