Skip to content

[QUESTION]: Why does neo4j_graphrag, a framework for hybrid retrieval, not support tag filtering #443

@chenxiaopeng-com

Description

@chenxiaopeng-com

Question

Why does neo4j_graphrag, a framework for hybrid retrieval, not support tag filtering
What serious problems would arise if I were to modify it to support

if entity_type == EntityType.NODE:
    if search_type == SearchType.HYBRID:
        if filters:
            **raise Exception("Filters are not supported with hybrid search")**
        if ranker == HybridSearchRanker.NAIVE:
            query = _get_hybrid_query(neo4j_version_is_5_23_or_above)
        elif ranker == HybridSearchRanker.LINEAR and alpha:
            query = _get_hybrid_query_linear(
                neo4j_version_is_5_23_or_above, alpha=alpha
            )
        else:
            raise InvalidHybridSearchRankerError()
        params: dict[str, Any] = {}
    elif search_type == SearchType.VECTOR:
        if filters:
            if (
                node_label is not None
                and embedding_node_property is not None
                and embedding_dimension is not None
            ):
                query, params = _get_filtered_vector_query(
                    filters,
                    node_label,
                    embedding_node_property,
                    embedding_dimension,
                    use_parallel_runtime,
                )
            else:
                raise Exception(
                    "Vector Search with filters requires: node_label, embedding_node_property, embedding_dimension"
                )
        else:
            query, params = NODE_VECTOR_INDEX_QUERY, {}
    else:
        raise ValueError(f"Search type is not supported: {search_type}")
    fallback_return = (
        f"RETURN node {{ .*, `{embedding_node_property}`: null }} AS node, "
        "labels(node) AS nodeLabels, "
        "elementId(node) AS elementId, "
        "elementId(node) AS id, "
        "score"
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions