Create index on type *and* label when using Tinkerpop3? - tinkerpop

Tinkerpop 3 introduces the great concept of labels. We are heavily using this feature where it identifies the schema used.
However, i see no support for labels when using indexes:
Graph#createIndex(String key, Class<E> elementClass)
Is there any way to create label specific indexes?
UPDATE
I am using TinkerGraph (in memory reference implementation).

Related

What is the default index in Cassandra?

I am using cassandra DSE 6.8. I know that there are several indexes used in Cassandra: 2nd index, SASI, SAI, search index, ...
When I create an index on a column:
CREATE INDEX status_idx ON table_name (status);
What is the name of default index ?
There is only one native index in open-source Cassandra, commonly referred to as secondary index. All indexes created with the CQL command CREATE INDEX are secondary indexes.
Alternatively, the SSTable-attached secondary index (SASI) is a custom index and therefore needs to be explicitly created with the keyword CUSTOM and the custom class SASIIndex specified:
CREATE CUSTOM INDEX ... USING 'org.apache.cassandra.index.sasi.SASIIndex'
Note that SASI is considered experimental by the Cassandra community and is disabled by default as I've explained in this post -- https://community.datastax.com/questions/12403/. They are not recommended for use in production.
DataStax Enterprise which ships with production-certified distributions of Apache Cassandra has an advanced DSE Search feature that allows users to perform complex full-text Solr searches on CQL tables indexed with Lucene. The custom indexes are created with the class Cql3SolrSecondaryIndex:
CREATE CUSTOM INDEX ... USING 'com.datastax.bdp.search.solr.Cql3SolrSecondaryIndex'
Astra DB, a fully-managed cloud-native Cassandra-as-a-service, includes the new Storage-Attached Indexing (SAI), a globally-distributed index for Cassandra. Indexes are created using the custom class StorageAttachedIndex:
CREATE CUSTOM INDEX ... USING 'StorageAttachedIndex'
The SAI enhancement in not yet available in open-source Cassandra but has been donated by DataStax and is awaiting acceptance by the Cassandra project (see CEP-7, CASSANDRA-16052). Cheers!
In this case, since a name has been provided, it will be status_idx. If a name was not provided, one is auto-generated based on the table and column:
table_name + _ + column_name + _idx
So in this case, it would be:
table_name_status_idx
Edit
Ahh…I get it now.
CREATE INDEX creates a secondary index.
CREATE CUSTOM INDEX creates a SASI index.

How to model/publish tables with composite keys in CloudConnect

I'm trying to understand how in CloudConnect Designer to model and publish (in my ETL graph) 2 tables with composite keys.
Example:
TableA has columns foo and bar.
TableB has columns foo and baz
Even though the column names are different, our old reports joins on both a.foo=b.foo and a.bar=b.baz.
Our schema is a bit of a mess.
For this scenario, I want TableA and TableB loaded in my graph so I can select attributes from both tables in my report.
I don't see any use cases that describe composite keys in the modeling guide.
Is there a common way to handle composite key relationships when bringing those tables into CloudConnect?
NOTE: I'm a software engineer without much data warehouse experience. I've been able to model and publish several other tables and their relationships that have only a single primary key. And, this isn't going straight to production or anything. I'm merely trying to learn and mimic an existing report we have in one of our applications.
I'm not sure if I understand the question well but in general - CloudConnect has no direct support for composite keys.
If the fields foo and bar (and analogically foo and baz in the second table) should serve as composite key you have to create special attribute in LDM and this attribute will be loaded during ETL with value which concatenate foo and bar for given row. You can use then this specially created attribute as a primary key (connection point) or reference in LDM.
Composite keys are called grain, and a recent software update to CloudConnect now has support for grain. I should mention though, be very careful when adding grain to existing data. You will likely have to do a full load, replacing all existing data (in the relevant table) in gooddata.
I have had experience where the publish fails in the synchronize step due to some existing data which goes against the grain. In that case to a synchronize dataset on it.

Controlling schema created by Database.Persist

I'm learning Haskell, and my first real app is a web application using Yesod + Database.Persist with the SQLite backend, but I can't find a way to specify some things with the persistLowerCase quasi quoter:
How to declare a specified column should be indexed (without the uniqueness constraint)
How to specify foreign keys (I can only do foreign_table_id ForeignTableId, which translates to "foreign_table_id" INTEGER NOT NULL REFERENCES "foreign_table")
How to specify column sizes (VARCHAR(50), for instance)
How to use CHAR and BLOB as a column type
The last two are not useful for SQLite proper, but I might change database backends in the future.
If I remember correctly (from a presentation about Yesod at InfoQ), adding an index must be done manually, there's no support in Yesod for doing it automatically.
Column sizes can be specified by typing maxlen=<size> in the field definition. BLOBs can be stored as a ByteStrings. An example for both fields looks like this:
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Something
b ByteString
t Text maxlen=30
|]
The BLOB data type will work with Sqlite3, since I've used it in the past, but I don't know for sure about the maxlen attribute, I just read about it. You can find more details in the Yesod book, chapter about Persistent.
As for the foreign keys, my experience tells me that those are synonyms. Just don't forget to enable foreign keys, since they're disabled by default.

Creation of compund unique contraint in neo4j 2.0

i'm using neo4j to create a versioned graph database, and i'm having some troubles to implement unique constraints in the database.
I want to know if is possible to do something like
CREATE CONSTRAINT ON (u:CaliopeUser) ASSERT u.timestampt+u.name IS UNIQUE
Or any other idea about how to implenment the uniqueness constraint in neo4j for a versioned database.
In 2.0 compound schema indexes are not possible. The recommended workaround is to create another property holding the compound value (maybe a transactionEventHandler might help with automating this) and use a index on that property.
I expect support for indexes on compound properties in some future release.

Neo4j Unique Labelled Node

Note: I am working with Neo4J 2.0.0-M02.
In previous applications, who worked with earlier versions of Neo4j (mostly 1.8.x), I've used the UniqueNodeFactory with an index on for instance, a person id. This way, I was able to create a node, only when it was needed. Because of the performance difference, I did not want to use the CREATE UNIQUE statement in Cypher, but use the Core API class:
http://api.neo4j.org/2.0.0-M02/org/neo4j/graphdb/index/UniqueFactory.UniqueNodeFactory.html
Now, in v2.0.0-M02, I don't longer use legacy indices, but I use the schema indices based on labels. My question is, are these indices compatible with the UniqueNodeFactory, and if so, what are their names that I need to pass as a parameter to the UniqueNodeFactory constructor?
I tried with passing the actual object, but the UniqueNOdeFactory is not compatible with the IndexDefinition class.
No they are not compatible, but instead 2.0 will add uniqueness constraints on label/property, enforcing such a uniqueness automatically. Perhaps M03 will contain it.