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 8945399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:14:15+00:00 2026-06-15T12:14:15+00:00

First of all, the technologies that we’re using are Neo4j, Spring and Spring Data

  • 0

First of all, the technologies that we’re using are Neo4j, Spring and Spring Data Neo4j (all latest stable versions).

We’re having the requirement that users should be able to search for all our entities seperately and also to provide all global search for all entities. I’m hoping the gather suggestions on how to implement the global search. Below is some (simplified!) code that shows how I query my entities. Each entity uses its own Lucene index.

The entity structure:

@NodeEntity
public abstract class BaseEntity {

    @GraphId
    private Long id;

}

@NodeEntity
public class A extends BaseEntity {

    private static final String INDEX = "A_Index";

    public static final String SEARCH_QUERY = "START a=node:" + INDEX + "({name}) RETURN a";

    @Indexed(indexType = IndexType.FULLTEXT, indexName = INDEX)
    @NotBlank
    private String name;

}

@NodeEntity
public class B extends BaseEntity {

    private static final String INDEX = "B_Index";

    public static final String SEARCH_QUERY = "START b=node:" + INDEX + "({name}) RETURN b";

    @Indexed(indexType = IndexType.FULLTEXT, indexName = INDEX)
    @NotBlank
    private String name;

}

The repository classes:

@Repository
public interface ARepository extends GraphRepository<A> {

    @Query(A.SEARCH_QUERY)
    List<A> find(@Param("name") String name, Pageable pageable);

}


@Repository
public interface BRepository extends GraphRepository<B> {

    @Query(B.SEARCH_QUERY)
    List<B> find(@Param("name") String name, Pageable pageable);

}

How I access the repository classes (again, very simplified):

@Service
public class Service {

    @Autowired
    private ARepository repository;

    public List<A> search(final String name) {
        return repository.find("name:*" + name + "*", null);
    }

}

So, this all works great when you search a single entity type. Could someone suggest what the best approach is the implement a global search which searches for every entity type?

Thinks I’ve been thinking about:

  • Use a single Lucene index, instead of an index per entity. Provide a
    fieldName in @Indexed like “a.name” or “b.name”. Then use every field
    name in a single query like “globalIndex:(a.name:foo OR
    b.name:foo). (actually not sure whether this is possible)

  • Launch a separate search call for every entity type and combine the
    results. It will be difficult to implement paging and sorting based
    on the index score though.

I’m not worried about performance, because we’ll be using a relatively small dataset.

A final question: are the results that are returned from a Cypher Lucene query always sorted on their index score? If not, how should I do this in SDN?

  • 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-15T12:14:16+00:00Added an answer on June 15, 2026 at 12:14 pm

    I think your first option makes the most sense.

    In general you can also use indexLevel=Level.CLASS to get a global index over all your entities (or use the same index-name for all). And then during the query if you want to filter by type also add a where filter: where a.__type__ = {fqn} fqn being the fully qualified name (or if you use @TypeAlias that value)

    Right now sorting by score is not supported, in general cypher only sorts by things you can access in the graph directly.

    P.S. It would be cool though to have an annotation that takes multiple @Indexed annotations on a single field and then honor all of them (although that will introduce issues if you want to infer an index from a field). Feel free to raise an issue on the SDN JIRA

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

Sidebar

Related Questions

First of all, let me say that I am not a professional coder -
First all, I am still learning CakePHP and I am close to ZERO using
First of all I need to say that I'm newbie in Java and Java-related
i have this code which i use in order to extract first all users
When using DbContext in a database-first scenario I found out that adding and deleting
First of all, this isn't for a keylogger, it's for an input in a
first of all some details: I configured security as below in web.xml view plaincopy
First of all, I'm quite new to the Android and JAVA world (coming from
first of all i would like to say i know its probably an easy
First of all there is probably a question like this already but i couldn't

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.