1
votes

I am using Titan 1.0.0 with Cassandra as storage backend and elasticsearch as indexing backend, want to model a complex graph with multiple vertices and edges. I've following considerations to make:

  1. Should I chose to have multiple MixedIndexes with single property each OR single MixedIndex with multiple properties?

    mgmt.buildIndex('nameAndAge',Vertex.class).addKey(name,Mapping.TEXT.getParameter()).addKey(age,Mapping.TEXT.getParameter()).buildMixedIndex("search")
    

OR

mgmt.buildIndex('nameMixed',Vertex.class).addKey(name,Mapping.TEXT.getParameter()).buildMixedIndex("search")
mgmt.buildIndex('ageMixed',Vertex.class).addKey(age,Mapping.TEXT.getParameter()).buildMixedIndex("search")

if I've to chose singel Mixed index with multiple properties then can it span across properties on edges and vertices OR is there any guideline?

  1. Is it better to have properties shared across Vertices / Edges? Meaning I want to have property "onDate" and have it for edges "Registered", "MarriedTo", "AgreedToTerms" and vertices "Order", "Travel".

Shall there be any special considerations if that property need to have index?

1

1 Answers

2
votes

Have a look here at what documatation says

Mixed indexes retrieve vertices or edges by any combination of previously added property keys.

And now for your first question,

  • if you aim at using single index to query any/all of the properties at one, use just one mixed index. Say you want to have one single

Example

String query="v.*:Phani"; // searches any property in the index with a value that includes `Phani`
Iterable<TitanIndexQuery.Result<TitanVertex>> result = titanGraph.indexQuery("name_mixed_index", query).vertices();

This searches all properties of the mixed index you created. If you added 10 properties added to this index, it will search the 10 and so on.

  • If you aim at querying one property only then use composite index. It's much faster.

My recommendation, use a single mixed index for all properties of interest so you could query them all at once or query them with any combination you like. If you want a single index, use composite index for it.

For your second question,

You can't share the same property value across indexes and edges. But you could have the same name of the property among all of them. If you intend to query a single property, aim for composite indexes.

In short,

Interested in making a query that includes multiple values or involve ordering? use mixed index with multiple properties. # Interested in making a query on only one property, use composite index.

More about this, read the documentation here for Indexing in Titan 1.0.0.