Release 25 May 2019

Browsing Neo4j data with Siren: For fun and fraud fighting (updated!)

Author: Giovanni Tummarello
Author Giovanni Tummarello
Browsing Neo4j data with Siren: For fun and fraud fighting (updated!)

When are graph DBs indispensable?

Many fraud detection systems rely on checking for relationships between domain entities.

To fight review fraud, for example, we might want to discard reviews of an item made by the creator of that item, such as a movie. More subtly, we might also want to discard reviews that were made by his or her friends.

While the above are fixed-length relational queries, which are perfectly suitable in a relational DB, sometimes anti-fraud checks need to use variable-length relational queries. For example, we might want to discard any review from reviewers that are connected by two or more degrees of separation, regardless of the relationship – a friend, a co-writer, a spouse, and so on.

For this last class of queries, graph databases with their traversal-optimized data structures are often the only realistic solution – let alone the ease and flexibility that their graph-centric query languages allow when asking these sort of questions.

Furthermore, graph databases are great at calculating other important queries that return the importance of nodes with respect to centrality and other useful node and network metrics.

Support for graph databases in Siren Platform 10.3: The new Import Wizard (beta) for the Neo4j connector 

Siren Platform version 10.2 introduced Siren’s first level of support for graph databases. Siren 10.3 introduces a simple and intuitive import wizard that makes it easy to import data from a Neo4j datasource, without the need for external command line operations. 

This might be surprising: Have we not already demonstrated that to get the benefit of knowledge graphs, you don’t need to move all of the data to a graph database?

Yes we have.

In the Siren Platform, you can simply connect the tables of any RDBMS (or Elasticsearch or other back-end table) and, by using the definition of a simple data model, you can enjoy scaled navigation, examination, search, and visual link analysis. (See our videos for more information).

However, as discussed, there are use cases where graph databases are very useful. And for these we now have a connector.

Now, with Siren Platform you can:

Since our graph database support is in its early stages, there are some limitations that we’ll discuss toward the end.

How it works

A graph database like Neo4j uses a model known as a property graph. This is data stored in either edges or nodes, which can be considered much like database tables that are relationally connected to each other. In Neo4j, nodes or edges can contain JSON syntax, so the database allows complex fields.

Siren Platform version 10.2 includes a Neo4j datasource, which can be used for reflection jobs. This can be used to stay in sync with selected slices of Neo4j, where one slice represents a node or an edge type.

While Siren 10.2 required you to run a script to create reflection jobs for Neo4j, Siren 10.3 offers an easy to use Import Wizard that automatically creates them for you.

The Import Wizard does the following:

  1. Analyzes the Neo4j schema to assess which types, relations, and which attributes for types and relations exist.
  2. Creates a series of reflection jobs. These are scheduled jobs that create for each relation or type a corresponding populated index in Siren Platform. These reflection jobs can be executed on a one-off basis or can be scheduled to automatically rerun.
  3. Creates the data model in Siren Platform:
    1. It creates an index pattern searches for each node or entity type. From here, it is easy to create analytic dashboards and visualizations.
    2. It populates the relations in the Siren data model with the same relations those entities and node records have in Neo4j. This enables relational navigation across dashboards and in the Link Analysis tool.

Once this procedure is executed, dashboards can be generated in Siren Platform from the data now contained in index pattern searches and graph analytics can be executed.

Prerequisites

Step-by-step example

In this example, we will detect review fraud by using the following schema:

Siren and Neo4J
  1. Configure the datasource by navigating to Management tab and clicking on Datasources.
  2. In the New Datasource Type dropdown, click JDBC.
  3. Specify the details for the Neo4j as the datasource, then click Save.
  4. Now go to the Data Reflections tab and click Reflection Jobs and add a new job.
  5. Select Neo4j as the datasource; you will now see an option to use the Neo4j Importer.
  6. Click Use Neo4j Importer. The Neo4j Import Wizard screen opens.
  7. Select the required nodes from the Select Nodes dropdown, and click Next.
    neo4j_step1.png
    All data reflection jobs for nodes and relations are displayed. Note that relations are also listed under Node Name; this is because Neo4j relations contain data, and Siren Investigate runs a reflection job for each relation, just like a node.
    neo4j_step2a.png

    Note: Ensure that an appropriate primary key is selected. The use of stable unique identifiers as primary keys in your Neo4j data model is recommended.
  8. Click Confirm.

    Wait for the data to start reflecting, which means that all jobs have indexed at least one document, indicating that the fields are mapping successfully. The Continue button becomes enabled at this point.

    While a job is indexing, its status is shown as running; when a job completes, the status changes to successful.
    neo4j_reflect.png

    You can leave the wizard at this point (by clicking on top left of the wizard, or anywhere else in the application). This may be necessary if reflection jobs are failing
  9. You can continue where you left off by following the notification in the Datasource Reflection Jobs page. Click Pending Jobs.
    neo4j_pending_jobs.png
  10. Click Continue Neo4j Job.
    neo4j_continue_job.png

    Note: Pending jobs are stored in server cache, which will be wiped out if the Investigate server is restarted or shut down. Its behaviour is unpredictable when multiple Investigate instances are running behind a Load Balancer.
  11. On the Configure Saved Searches screen, you can modify the search name, and specify a color for the nodes and relations:
    neo4j_copy.png

    Click Next.
  12. On the Configure Relations screen, you can modify the Relation Label and the Inverse Relation Label for each relation:
    neo4j_relations.png
  13. Click Create Ontology.
  14. Return to Siren Platform and go to the Management tab → Click the Data Model tab, where you can see all indices that were created and all of the relationships that were found. From this screen, select icons for each search and enter a label in the Label when visualized in the graph browser field.
    Siren index pattern search for Neo4j

    Click on the data model graph tab to see the data model. It is recreated in Siren Platform automatically from the Neo4j structure.
    Siren index pattern search for neo4j 2

Creating dashboards and navigating the graph with Siren Platform link analysis

Now that Index Pattern Searches and a relational data model is in place, all you have to do is to create dashboards and use the Link Analysis navigator.

To learn how to do this, we recommend that you complete our getting started tutorial

However, the quickest way is by using our automatic dashboard creation wizard:

  1. In the Management app, click the Data Model tab and select the search that you want to create a dashboard for.
  2. Click the Data tab and either select the fields that you’d like to create widgets for or simply click Autoselect Most Relevant.
  3. Click Create dashboard.
  4. Repeat steps 1-3 for other index patterns of interest. You might want to do this for what previously were edges, such as “acted_in”. This will give you the dashboard-to-dashboard navigation capabilities.

Now, you can explore Siren Platform’s unique link analysis capabilities:

Siren and Ne4j link analysis

And now… Let’s hunt down the fraudsters

As we mentioned earlier, the main reasons to use graph databases are to run arbitrary-length path queries efficiently or to execute graph metrics.

In fraud detection, an investigator might want to detect a suspect circle of users. For example, users that are connected to each other by at least two fraudulent hub nodes.

Neo4j is efficient at calculating large-scale graph metrics, such as centrality, page rank and others. These can be useful metrics to assess the relative importance of a node.

How can you avail of these capabilities in Siren Platform?

For pattern detection

You create a new data ingestion where the pattern-detecting query (in cypher) is used as the input.

This creates an index in Elasticsearch with a list of suspects. The query can then be re-executed manually or automatically by implementing scheduling.

In the example below, we specified a datasource query to identify “reviewers who are also Authors”:

Siren and Neo4j suspect reviews

After this special data ingestion is performed, you create an index pattern search for this newly created index. In the data model, you link the keys to the records that have already been ingested, for example, link the table “suspect_circles” and the field “IDs” with the “persons” field ID.

These results are easy to use in Siren Platform, both in dashboard-to-dashboard relational navigation and on the graph. For example, simply import the query result index in the graph and expand it to reveal the records that are involved in the circles.

Siren link analysis powered with Neo4j

You can repeat the procedure for as many fraudulent patterns as required. And the data reflection jobs can be scheduled to run at set intervals.

For graph metrics to be shown in Siren Platform

You can modify the reflection jobs that you have created to produce a graph metric result, such as centrality, which is written as an extra field at the reflection phase. This can then be leveraged in dashboards or on the graph, for example, you can use it in a lens to make a node look bigger.

Firing a Neo4j query from the Siren Platform

Siren 10.3 provides the ability to trigger Neo4j queries directly from its graph browser. You can write as many scripts as you like and invoke them from the Graph Browser’s “Contextual Menu” (available on right click). 

Here are the steps to add the shortest path query script to the graph browser and find the shortest path between 2 or more (Neo4j Reflected) data nodes.

  1. Use the Neo4j Wizard to import your Neo4j data.
  2. Navigate to Management → Scripts and create a new script by selecting the Type “contextual”, paste the script provided here in the Source section and click on “Save”.
    firing neo4j query
  3. Go to the graph browser and click the Edit button at the top panel to enter edit mode and click the edit option on the graph browser. On the Options tab on the left, click on the “Add Contextual Script” button under the Contextual Function. Select the newly created script from the drop down button to add it to the graph browser.
    image

Click on Save. You can now use this script to compute shortest paths between your selected (Neo4j Reflected) data nodes. 

To run the query script, simply add the Neo4j reflected nodes on the graph browser, select the required nodes, right click and select “Neo4j Shortest path” (the name of the script).

neo4j shortest path

Enter the maximum path length and click OK.

firing neo4j query 4

You will see the shortest path between the nodes appears.

image

Conclusion: Using the best tool for the job

In the past two years, graph databases have gained more and more momentum. While, occasionally, one might encounter some very far-reaching graph database projects, it is clear that IT departments won’t be ditching Hadoop, Spark, or Elasticsearch for big data logs anytime soon – nor should they.

One of Siren Platform’s unique and exciting aspects is that it allows navigating knowledge graphs without the need for an extract-transform-load (ETL) process for graph databases.

In the Siren Platform, the graph is in the data you already have and you can also leverage the back-end system that you already use. For more information, see our blog post about Siren Platform’s “virtualization or reflection” capabilities.

For example, the following screenshot shows aggregates on call data records that are stored in a connected Elasticsearch index. In this case, no graph database was used:

Siren and Neo4j Link Analysis

We are excited to share our support for graph databases with the popular Neo4j.

Siren Platform can now employ “the best tool for the job” for financial fraud detection, law enforcement, intelligence, and more.

For the end user, the boundary is invisible: one sees data which is in graph DBs simply connected to that which is in other back ends, both in the link analysis and in Siren’s signature “dashboard to dashboard” navigation.

What’s next?

We have a rich road map of improvement with respect to graph database support:

Do you like what you see? Would you like to see support for another specific graph database?

Drop us a note in our community or contact us directly.

We look forward to hearing from you and we support your success in your Enterprise Knowledge Graph project.


Also published on Medium.

OTHER AREAS

Explore our topics

Close