Reputation: 31
I am experimenting/learning spring data neo4j. I have a very simple app that stores tweets from twitter. Please see a snippet below.
@NodeEntity
public class Tweet {
@GraphId
private Long id;
private String tweet;
@Indexed
Set<String> hashtags;
The question is, what is the best way to store hash tags so that I can quickly get at the tweet to which they belong? What I can think of is either using @Indexed over the Set or actually creating a separate Hashtag NodeEntity and put a relationship between it and the tweet. I cannot find any documentation on indexing a collection in a NodeEntity, so I'm not sure if an index is created on a the set object or an each String in the Set is indexed. Any suggestions would be good. Thanks.
Upvotes: 1
Views: 260
Reputation: 7521
When you do an @Indexed
it get put into Neo4j's Indexing system, which is Lucene. Lucene doesn't actually index the collections, but rather the string representation of the collection.
As for your Data Model, I would go with creating a HashTag
Node which each Tweet would connect to. You'll eventually run into the Dense Node problem for more common Hash Tags, but over all it'll allow you to do more analytics, such as getting all tweets with the same Hash Tag.
Upvotes: 5