How to do indexing in Janusgraph Or Gremlin

--

First step :remote connect tinkerpop.server conf/remote.yaml session

Second Step :remote config timeout none

Third Step :remote console

Fourth Step graph.getOpenTransactions().size();

Fifth Step for(i=0;i<size;i++) {graph.getOpenTransactions().getAt(0).rollback()}

Note:- Replace size with output of fourth step

Sixth Step mgmt = graph.openManagement()

Seventh Step name = mgmt.getPropertyKey(‘name’)

Eighth Step bynameindex=mgmt.buildIndex(‘byNameComposite’, Vertex.class).addKey(name).buildCompositeIndex()

Ninth Step mgmt.commit();

Tenth Step ManagementSystem.awaitGraphIndexStatus(graph, “byNameComposite”).call();

Eleventh Step mgmt = graph.openManagement()

Twelfth Step mgmt.updateIndex(mgmt.getGraphIndex(“byNameComposite”), SchemaAction.REGISTER_INDEX).get();

Thirteenth Step mgmt.commit()

Fourteenth Step mgmt = graph.openManagement()

Fifteenth Step mgmt.updateIndex(mgmt.getGraphIndex(“byNameComposite”), SchemaAction.REINDEX).get()

Sixteenth Step mgmt.commit()

Seventeenth Step prop = mgmt.getPropertyKey(‘name’);

Eighteenth Step idx = mgmt.getGraphIndex(‘byNameComposite’);

Nineteenth Step status = idx.getIndexStatus(prop);

Twentieth Step print(status)

Hurray, You have enabled the property for indexing.

Now, Use it as follows.

g=graph.traversal()

g.V().property(‘name’,’Sumit’)

Now, you will get the result, before you can even blink your eyes, Even if you have billions of nodes.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response