Introducing ArangoDB

ArangoDB is a multi-model database with the ability to store data as graphs, documents, and key-value.





Took material from a free course on Udemy and Outline of the course 

It is worth paying attention to the  training center and  docks





You can work on the HTTP API , frontterminal and python library





Concept

ArangoDB stores objects in json documents with support for key reversal, for which a special _key field is  responsible .





There are two types of collections:





  • Standard. Json document store, special fields _key, _rev, _id key can be set yourself. The last two are created automatically.





    • _key is the key of the object in the collection. IMPORTANT: case sensitive





    • _rev - used for internal algorithms





    • _id - used to communicate with other collections. It has the format {collection name} / _ key





  • Edge. Special collections that store the objects of communication between the objects of standard collections. I have two additional fields _ to, _from , which store the _id of objects, which the edge object connects





.

.





CRUD

AQL





. , _key .









INSERT {key: value} INTO collection [RETURN NEW]
      
      



RETURN NEW







:





RETURN DOCUMENT(_id) –    _id 
RETURN DOCUMENT(collection_name, [_key, ...]) –       
      
      











UPDATE {_key: "value"} WITH {newVal: 1234} IN collection
      
      







REMOVE {_key: "value"} IN collection
      
      



FOR

: FOR variableName IN expression

















Update :





FOR doc in ["key1", "key2"]:
  UPDATE doc WITH {newVal: 1234} IN collection
      
      



. _key, _id, _to _from .





7 :





  • Primary – _key _id





  • Edge – _from _to





  • Hash –





  • Skiplist





  • Persistent





  • Geo





  • Fulltext





Selectivity,





: FILTER condition





.

, :





FOR flight IN flights 
  FILTER flight.type == "VIP" 
  RETURN flight
      
      



.







, .





FOR airport IN airports
  FILTER airport.city == "Dallas"
    FOR flight in flights 
      FILTER flight._to == airport._id
      RETURN {"airport": airport.name, "flight": flight.FlightNum}
      
      



:





COLLECT variableName = expression options
      
      



, :





FOR airport IN airports COLLECT state = airport.state RETURN state
      
      







FOR airport IN airports
  COLLECT state = airport.state WITH COUNT INTO total
  SORT total DESC
    RETURN {"state": state, "total":total}
      
      



(edge collections). _id, .

edge _to _from, _id , . json, , .





:





FOR vertex, edge, path IN 1..1 OUTBOUND _id GRAPH edge_collection RETURN path
FOR vertex, edge, path IN 1..1 OUTBOUND _id edge_collection RETURN path –  ,     GRAPH.    edge 
      
      



vertex – ,

edge –

path – :





IN , min..max

OUTBOUND/INBOUND/ANY . _from, _to .

_id id .

GRAPH edge ,





, - :





FOR airport in airports
  FILTER airport.city == "San Francisco"
    FOR v, e, p IN 1..1 OUTBOUND airport flights
    FILTER v._id == "airports/KOA"
    RETURN p
      
      



- :





FOR airport in airports
  FILTER airport.city == "San Francisco"
    FOR v, e, p IN 2..3 OUTBOUND airport flights
    FILTER v._id == "airports/KOA"
    RETURN p
      
      



, .





ArangoSearch, .

, ,





ArangoSearch : .





– analyzers, views links

Analyzers , . . .

Views  , /

Links  views . .





Integration engine  - data provision layer.

Search  is a preprocessor, works on views, can only see indexed fields, that is, those that we described in links.

Rank  allows you to get the weight of the results, according to the search request. We can also set our own weights for the search parts.





An example of finding the word "ninja" in a movie description:





FOR doc in view
  SEARCH ANALYZER(d.description == "ninja", "text_en")
  RETURN doc
      
      






All Articles