Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:50:59+00:00 2026-06-02T23:50:59+00:00

I’m wonderring what’s a better approach when needing to have multiple indecies based on

  • 0

I’m wonderring what’s a better approach when needing to have multiple indecies based on some node type or field.
For example, let’s say I want to have a graph of students and want to index them by their school and id.

As I understand I can have an index per school like this:

// add student
Index<Node> index = this.graphDb.index().forNodes(schoolName);
Node node = this.graphDb.createNode();
node.setProperty("id", studentId);
index.add(node, "id", studentId);

// get student
Index<Node> index = this.graphDb.index().forNodes(schoolName);
Node node = index.get("id", studentId).getSingle();

I can on the other hand use one index and do something like:

// add student
Index<Node> index = this.graphDb.index().forNodes("schools");
Node node = this.graphDb.createNode();
node.setProperty("id", studentId);
index.add(node, schoolName + ":id", studentId);

// get student
Index<Node> index = this.graphDb.index().forNodes("schools");
Node node = index.get(schoolName + ":id", studentId).getSingle();

What is a better approach?
Any advantages to one over the other?
Especially performance wise or storage wise, when there are a lot of nodes involved.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:51:01+00:00Added an answer on June 2, 2026 at 11:51 pm

    Your approach is perfectly valid.
    If you want to query all students of a school you can use:

    Iterable<Node> pupils = index.query(schoolName + ":*");
    

    You can also just add both fields to the index:

    index.add(node, "schoolName", studentId);
    index.add(node, "id", studentId);
    

    and then query them by a combined query

    Iterable<Node> pupils = index.query("schoolName:"+schoolName + " AND id:"+id);
    

    The first one is smaller in index size but the second one is more powerful.
    Performance wise it won’t make such a big difference (but you can test it and report back).

    You could also use an structure in the graph where a school is a node and the pupils are attached to it by a LEARNS_AT relationship which can also have a start and end temporal property, so it is easier to model your domain. See this demo graph

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.