Documentation   >   Network database   >   Network Query Language - Data quering
 
Overview
Manipulation
Modification
NQL Extension
Java Client


SELECT
Select by attribute filter Inside () possible any boolean expressions with attribute-value pairs.
Special expression is CONNECTED (...) it check attributes in connected elements.
Some pseudo queries look like:
SELECT () - select entities

SELECT (atribute1='value1')

SELECT (atribute1='value1' AND (attribute2='value2' OR attribute3='value3'))

Example:
Get entities with attribute filter name='Mike'

SELECT (name='Mike')
Execute NQL command

(...) clause can have boolean condition any complexity you need. E.g. We could extend previous query to more complex:

SELECT (
          (first_name='John' AND last_name='Smith') 
          OR 
          (first_name='Mike' AND last_name='Johnson')
        )
Execute NQL command

Select network by path filter. It's similar to XML XPath querying.

SELECT  (...) ( / (...) ) *

Examples:

SELECT 
  (first_name='John') 
  / (name='brother-sister') 
  / (first_name='Marry') 
  / (name='study at') 
  / ((name='High School' AND address='USA, Idaho, Boise, XYZ'))
Execute NQL command

Find if some entities are connected within some distance.

SELECT () 
/ [ depth='X'
    (USEONLY(...))?
    (IGNORE(...))?
  ]  
/ () 

Inside [...] is specified connection depth and patterns (USEONLY | IGNORE) for connections. Examples:

SELECT 
  (name='Dog Roger' AND breed='terrier')
  / [ depth='5'] 
  / (name='HP Company' AND address='USA, Idaho, Boise')
Execute NQL command

or

SELECT (name like 'Roman*Empire*') 
/ [  
    depth='5' 
    USEONLY (CHN_TYPE='COUNTRY' name='country-previous-next') 
  ]
/ (name like '*Empire*') 
LIMIT 100
Execute NQL command

Output network size control. Max output network size is controlled by LIMIT clause.

SELECT ... LIMIT X 
SELECT (name like '*Empire*') 
/ [
   depth='2'
] 
limit 50
Execute NQL command

Filter clause. Max amount for specific entities is controlled by FILTER clause.

SELECT ...  
(FILTER(...)) ?

Example:
SELECT (name like '*Byzantine*') 
/ [
   depth='2'
] 
filter
( 
(name='country-previous-next') 5
)
limit 50
Execute NQL command

USEONLY, IGNORE clauses. Example of usage extension patterns: USEONLY and IGNORE.

SELECT (name like 'Roman*Empire*') 
/ [  
    depth='5' 
    USEONLY (CHN_TYPE='COUNTRY' name='country-previous-next') 
  ]
/ (name like '*Empire*') 
LIMIT 100
Execute NQL command

SELECT (name like '*Empire*') 
/ [
   depth='4'
   IGNORE (name='coin-related-to-country')
] 

limit 100
Execute NQL command

 
SQL
Convert network to a table and querying SQL
Command SQL get network from input, convert it to a table and apply SQL query against it.
SQL (query="SELECT * FROM table")
Usually it's used in pipe with SELECT command since it require input network.
Example:
SELECT (name='request' AND ip='127.0.0.1')  / (name='visited') / (product='laptop')   
| SQL (query="SELECT model FROM table WHERE product = 'laptop' ")

or

SELECT 
  (name='Dog Roger' AND breed='terrier')
  / [ depth='5'] 
  / (name='HP Company' AND address='USA, Idaho, Boise')
| SQL (query='SELECT * FROM table')
Execute NQL command
By default for SQL convertation and quering HSQLDB is used. Another JDBC compliant database database can be used.
JDBC data can be specified in query (jdbc key).
SELECT 
  (name='Dog Roger' AND breed='terrier')
  / [ depth='5'] 
  / (name='HP Company' AND address='USA, Idaho, Boise')
| SQL (query='SELECT * FROM table' jdbc='jdbc:mysql://localhost/myDB?user=myusername&password=mypassword')

Default JDBC data can be specified in config file (neuro4j.properties).

After convertation and quering temporary table is deleted. If you want to keep that table put drop_table='false' in SQL clause.

Powered by ESG