Neo4j Vector Index prefiltering

Hi all, I'm trying to leverage on the GenAI capabilities of Neo4J to retrieve meaningfull data through the vector index and embedding. I loaded some data into the database, I've created the embeddings and the relative vector index (using the cosine vector.similarity_function) on them and then I started to play with some queries. If I proceed with the query using CALL db.index.vector.queryNodes everything seems fast and ok; however there's a limitation here since I need to prefilter this query to focus the retrieval only on a specific set of data. I then tried to make my prefilter query and, with the retrieved nodes, I start to filter using vector.similarity.cosine. This time the results are ok but even with a very low amount of data, the query is taking 30 minutes to run; it seems that the indexes are not used? I have to say that the first query, on the same dataset, runs really fast, in milliseconds. What am I missing? it's really a blocker to not have a pre-filtering capability for many use cases. Thanks for anyone who can help me in sorting this out

Hi, the only way to query/utilize a vector index in a query is through the db.index.vector.queryNodes/db.index.vector.queryRelationships procedures, they are not picked up on through regular MATCH statements like a range index for example is.

For some extra information around why:

  • The documentation separates our index categories into two types, search-performance and semantic indexes:

    Neo4j supports two categories of indexes:

    • Search-performance indexes, for speeding up data retrieval based on exact matches. This category includes range, text, point, and token lookup indexes.
    • Semantic indexes, for approximate matches and to compute similarity scores between a query string and the matching data. This category includes full-text and vector indexes.
  • And then the documentation around querying vector indexes can be found here, Vector indexes - Cypher Manual.