Skip to content

Instantly share code, notes, and snippets.

@guyellis
Last active February 15, 2017 18:33
Show Gist options
  • Save guyellis/7d2a04a9b4295063e4ebbd6fe7e93ff8 to your computer and use it in GitHub Desktop.
Save guyellis/7d2a04a9b4295063e4ebbd6fe7e93ff8 to your computer and use it in GitHub Desktop.
// I create a script to generate this groovy - i.e. did not write it by hand
mgmt = graph.openManagement();
if(!mgmt.containsPropertyKey('TEXT_key_prop')){
k = mgmt.makePropertyKey('TEXT_key_prop').dataType(String.class).cardinality(Cardinality.SINGLE).make();
mgmt.buildIndex('TEXT_index_name', Vertex.class).addKey(k, Mapping.TEXT.asParameter()).buildMixedIndex('search');
mgmt.commit();
graph.addVertex('TEXT_key_prop', 'The quick brown fox JUMPS oVeR the lazy dog');
graph.tx().commit();
// Let index complete
Thread.sleep(2000);
} else {
mgmt.rollback();
}
mgmt = graph.openManagement();
if(!mgmt.containsPropertyKey('STRING_key_prop')){
k = mgmt.makePropertyKey('STRING_key_prop').dataType(String.class).cardinality(Cardinality.SINGLE).make();
mgmt.buildIndex('STRING_index_name', Vertex.class).addKey(k, Mapping.STRING.asParameter()).buildMixedIndex('search');
mgmt.commit();
graph.addVertex('STRING_key_prop', 'The quick brown fox JUMPS oVeR the lazy dog');
graph.tx().commit();
// Let index complete
Thread.sleep(2000);
} else {
mgmt.rollback();
}
mgmt = graph.openManagement();
if(!mgmt.containsPropertyKey('TEXTSTRING_key_prop')){
k = mgmt.makePropertyKey('TEXTSTRING_key_prop').dataType(String.class).cardinality(Cardinality.SINGLE).make();
mgmt.buildIndex('TEXTSTRING_index_name', Vertex.class).addKey(k, Mapping.TEXTSTRING.asParameter()).buildMixedIndex('search');
mgmt.commit();
graph.addVertex('TEXTSTRING_key_prop', 'The quick brown fox JUMPS oVeR the lazy dog');
graph.tx().commit();
// Let index complete
Thread.sleep(2000);
} else {
mgmt.rollback();
}
b = [:];
b.put('TEXT', ['quick': [
g.V().has('TEXT_key_prop', textContains('quick')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('quick')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('quick')).count().next(),
g.V().has('TEXT_key_prop', textRegex('quick')).count().next()
],
'quick fox': [
g.V().has('TEXT_key_prop', textContains('quick fox')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('quick fox')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('quick fox')).count().next(),
g.V().has('TEXT_key_prop', textRegex('quick fox')).count().next()
],
'quick Fox': [
g.V().has('TEXT_key_prop', textContains('quick Fox')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('quick Fox')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('quick Fox')).count().next(),
g.V().has('TEXT_key_prop', textRegex('quick Fox')).count().next()
],
'quick Foz': [
g.V().has('TEXT_key_prop', textContains('quick Foz')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('quick Foz')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('quick Foz')).count().next(),
g.V().has('TEXT_key_prop', textRegex('quick Foz')).count().next()
],
'qui': [
g.V().has('TEXT_key_prop', textContains('qui')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('qui')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('qui')).count().next(),
g.V().has('TEXT_key_prop', textRegex('qui')).count().next()
],
'^the': [
g.V().has('TEXT_key_prop', textContains('^the')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('^the')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('^the')).count().next(),
g.V().has('TEXT_key_prop', textRegex('^the')).count().next()
],
'^the quick': [
g.V().has('TEXT_key_prop', textContains('^the quick')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('^the quick')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('^the quick')).count().next(),
g.V().has('TEXT_key_prop', textRegex('^the quick')).count().next()
],
'^The': [
g.V().has('TEXT_key_prop', textContains('^The')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('^The')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('^The')).count().next(),
g.V().has('TEXT_key_prop', textRegex('^The')).count().next()
],
'^The quick': [
g.V().has('TEXT_key_prop', textContains('^The quick')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('^The quick')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('^The quick')).count().next(),
g.V().has('TEXT_key_prop', textRegex('^The quick')).count().next()
],
'^quick brown': [
g.V().has('TEXT_key_prop', textContains('^quick brown')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('^quick brown')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('^quick brown')).count().next(),
g.V().has('TEXT_key_prop', textRegex('^quick brown')).count().next()
],
'quick brown': [
g.V().has('TEXT_key_prop', textContains('quick brown')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('quick brown')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('quick brown')).count().next(),
g.V().has('TEXT_key_prop', textRegex('quick brown')).count().next()
],
'lazy dog$': [
g.V().has('TEXT_key_prop', textContains('lazy dog$')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('lazy dog$')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('lazy dog$')).count().next(),
g.V().has('TEXT_key_prop', textRegex('lazy dog$')).count().next()
],
'dog$': [
g.V().has('TEXT_key_prop', textContains('dog$')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('dog$')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('dog$')).count().next(),
g.V().has('TEXT_key_prop', textRegex('dog$')).count().next()
],
'lazy doG$': [
g.V().has('TEXT_key_prop', textContains('lazy doG$')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('lazy doG$')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('lazy doG$')).count().next(),
g.V().has('TEXT_key_prop', textRegex('lazy doG$')).count().next()
],
'doG$': [
g.V().has('TEXT_key_prop', textContains('doG$')).count().next(),
g.V().has('TEXT_key_prop', textContainsPrefix('doG$')).count().next(),
g.V().has('TEXT_key_prop', textContainsRegex('doG$')).count().next(),
g.V().has('TEXT_key_prop', textRegex('doG$')).count().next()
],])
b.put('STRING', ['quick': [
g.V().has('STRING_key_prop', textContains('quick')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('quick')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('quick')).count().next(),
g.V().has('STRING_key_prop', textRegex('quick')).count().next()
],
'quick fox': [
g.V().has('STRING_key_prop', textContains('quick fox')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('quick fox')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('quick fox')).count().next(),
g.V().has('STRING_key_prop', textRegex('quick fox')).count().next()
],
'quick Fox': [
g.V().has('STRING_key_prop', textContains('quick Fox')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('quick Fox')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('quick Fox')).count().next(),
g.V().has('STRING_key_prop', textRegex('quick Fox')).count().next()
],
'quick Foz': [
g.V().has('STRING_key_prop', textContains('quick Foz')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('quick Foz')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('quick Foz')).count().next(),
g.V().has('STRING_key_prop', textRegex('quick Foz')).count().next()
],
'qui': [
g.V().has('STRING_key_prop', textContains('qui')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('qui')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('qui')).count().next(),
g.V().has('STRING_key_prop', textRegex('qui')).count().next()
],
'^the': [
g.V().has('STRING_key_prop', textContains('^the')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('^the')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('^the')).count().next(),
g.V().has('STRING_key_prop', textRegex('^the')).count().next()
],
'^the quick': [
g.V().has('STRING_key_prop', textContains('^the quick')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('^the quick')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('^the quick')).count().next(),
g.V().has('STRING_key_prop', textRegex('^the quick')).count().next()
],
'^The': [
g.V().has('STRING_key_prop', textContains('^The')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('^The')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('^The')).count().next(),
g.V().has('STRING_key_prop', textRegex('^The')).count().next()
],
'^The quick': [
g.V().has('STRING_key_prop', textContains('^The quick')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('^The quick')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('^The quick')).count().next(),
g.V().has('STRING_key_prop', textRegex('^The quick')).count().next()
],
'^quick brown': [
g.V().has('STRING_key_prop', textContains('^quick brown')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('^quick brown')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('^quick brown')).count().next(),
g.V().has('STRING_key_prop', textRegex('^quick brown')).count().next()
],
'quick brown': [
g.V().has('STRING_key_prop', textContains('quick brown')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('quick brown')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('quick brown')).count().next(),
g.V().has('STRING_key_prop', textRegex('quick brown')).count().next()
],
'lazy dog$': [
g.V().has('STRING_key_prop', textContains('lazy dog$')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('lazy dog$')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('lazy dog$')).count().next(),
g.V().has('STRING_key_prop', textRegex('lazy dog$')).count().next()
],
'dog$': [
g.V().has('STRING_key_prop', textContains('dog$')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('dog$')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('dog$')).count().next(),
g.V().has('STRING_key_prop', textRegex('dog$')).count().next()
],
'lazy doG$': [
g.V().has('STRING_key_prop', textContains('lazy doG$')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('lazy doG$')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('lazy doG$')).count().next(),
g.V().has('STRING_key_prop', textRegex('lazy doG$')).count().next()
],
'doG$': [
g.V().has('STRING_key_prop', textContains('doG$')).count().next(),
g.V().has('STRING_key_prop', textContainsPrefix('doG$')).count().next(),
g.V().has('STRING_key_prop', textContainsRegex('doG$')).count().next(),
g.V().has('STRING_key_prop', textRegex('doG$')).count().next()
],])
b.put('TEXTSTRING', ['quick': [
g.V().has('TEXTSTRING_key_prop', textContains('quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('quick')).count().next()
],
'quick fox': [
g.V().has('TEXTSTRING_key_prop', textContains('quick fox')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('quick fox')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('quick fox')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('quick fox')).count().next()
],
'quick Fox': [
g.V().has('TEXTSTRING_key_prop', textContains('quick Fox')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('quick Fox')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('quick Fox')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('quick Fox')).count().next()
],
'quick Foz': [
g.V().has('TEXTSTRING_key_prop', textContains('quick Foz')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('quick Foz')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('quick Foz')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('quick Foz')).count().next()
],
'qui': [
g.V().has('TEXTSTRING_key_prop', textContains('qui')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('qui')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('qui')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('qui')).count().next()
],
'^the': [
g.V().has('TEXTSTRING_key_prop', textContains('^the')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('^the')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('^the')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('^the')).count().next()
],
'^the quick': [
g.V().has('TEXTSTRING_key_prop', textContains('^the quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('^the quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('^the quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('^the quick')).count().next()
],
'^The': [
g.V().has('TEXTSTRING_key_prop', textContains('^The')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('^The')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('^The')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('^The')).count().next()
],
'^The quick': [
g.V().has('TEXTSTRING_key_prop', textContains('^The quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('^The quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('^The quick')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('^The quick')).count().next()
],
'^quick brown': [
g.V().has('TEXTSTRING_key_prop', textContains('^quick brown')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('^quick brown')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('^quick brown')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('^quick brown')).count().next()
],
'quick brown': [
g.V().has('TEXTSTRING_key_prop', textContains('quick brown')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('quick brown')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('quick brown')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('quick brown')).count().next()
],
'lazy dog$': [
g.V().has('TEXTSTRING_key_prop', textContains('lazy dog$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('lazy dog$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('lazy dog$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('lazy dog$')).count().next()
],
'dog$': [
g.V().has('TEXTSTRING_key_prop', textContains('dog$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('dog$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('dog$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('dog$')).count().next()
],
'lazy doG$': [
g.V().has('TEXTSTRING_key_prop', textContains('lazy doG$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('lazy doG$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('lazy doG$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('lazy doG$')).count().next()
],
'doG$': [
g.V().has('TEXTSTRING_key_prop', textContains('doG$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsPrefix('doG$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textContainsRegex('doG$')).count().next(),
g.V().has('TEXTSTRING_key_prop', textRegex('doG$')).count().next()
],])
b;
/*
Results reduced to CSV:
TEXT,quick,1,1,1,0
TEXT,quick fox,1,0,0,0
TEXT,quick Fox,1,0,0,0
TEXT,quick Foz,0,0,0,0
TEXT,qui,0,1,0,0
TEXT,^the,1,0,0,0
TEXT,^the quick,1,0,0,0
TEXT,^The,1,0,0,0
TEXT,^The quick,1,0,0,0
TEXT,^quick brown,1,0,0,0
TEXT,quick brown,1,0,0,0
TEXT,lazy dog$,1,0,0,0
TEXT,dog$,1,0,0,0
TEXT,lazy doG$,1,0,0,0
TEXT,doG$,1,0,0,0
STRING,quick,1,1,1,0
STRING,quick fox,1,0,0,0
STRING,quick Fox,1,0,0,0
STRING,quick Foz,0,0,0,0
STRING,qui,0,1,0,0
STRING,^the,1,0,1,0
STRING,^the quick,1,0,0,0
STRING,^The,1,0,0,0
STRING,^The quick,1,0,0,0
STRING,^quick brown,1,0,0,0
STRING,quick brown,1,0,0,0
STRING,lazy dog$,1,0,0,0
STRING,dog$,1,0,1,0
STRING,lazy doG$,1,0,0,0
STRING,doG$,1,0,0,0
TEXTSTRING,quick,1,1,1,0
TEXTSTRING,quick fox,1,0,0,0
TEXTSTRING,quick Fox,1,0,0,0
TEXTSTRING,quick Foz,0,0,0,0
TEXTSTRING,qui,0,1,0,0
TEXTSTRING,^the,1,0,0,0
TEXTSTRING,^the quick,1,0,0,0
TEXTSTRING,^The,1,0,0,0
TEXTSTRING,^The quick,1,0,0,0
TEXTSTRING,^quick brown,1,0,0,0
TEXTSTRING,quick brown,1,0,0,0
TEXTSTRING,lazy dog$,1,0,0,0
TEXTSTRING,dog$,1,0,0,0
TEXTSTRING,lazy doG$,1,0,0,0
TEXTSTRING,doG$,1,0,0,0
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment