Neo4j 警告:现有属性的 UnknownPropertyKeyWarning

问题描述 投票:0回答:1

尽管确认属性

Neo.ClientNotification.Statement.UnknownPropertyKeyWarning
存在于我的
embeddings
节点上,但我在 Neo4j 查询中遇到了
Asset

我有 31 个

Asset
节点,每个节点都有一个
embeddings
属性,维度为 768。确认所有节点的该属性都是非空的。

Cypher Query Check Property Exists

class Neo4jGraph:

    ...

    def best_matches(self, embedding: List[float], limit: int = 10) -> List[Dict[str, Any]]:

        query = """
        WITH $embedding AS input_embedding
        MATCH (a:Asset)
        WHERE a.embeddings IS NOT NULL
        RETURN a.id AS id, a.url AS url, a.description AS description, vector.similarity.cosine(input_embedding, a.embeddings) AS similarity
        ORDER BY similarity DESC
        LIMIT $limit
        """

        with self.driver.session() as session:

            result = session.run(query, embedding = embedding, limit = limit)
            assets = []

            for record in result:
                assets.append({
                    'asset_id': record['id'],
                    'asset_url': record['url'],
                    'description': record['description'],
                    'similarity': record['similarity'],
                    'asset_tags': record['tags']
                })

            return assets

运行上面的python代码时,遇到以下错误:

收到来自 DBMS 服务器的通知:{severity: WARNING} {code: Neo.ClientNotification.Statement.UnknownPropertyKeyWarning} {类别: 无法识别} {title:提供的属性键不在 数据库} {描述:查询中的属性名称之一不是 在数据库中可用,请确保您没有拼写错误或那个 当您在应用程序中运行此语句时,该标签可用 (缺少的属性名称是:embeddings)} {position: line: 4, 列:17,偏移量:84}

我想了解为什么当该属性存在且有效时我会收到此警告?而在 Neo4j Desktop 中运行相同的密码查询则可以正常工作。

neo4j cypher neo4j-python-driver
1个回答
0
投票

确保您在 python 和驱动程序中指向相同的数据库:

DB = "<your DB consistent with the one you're executing against in browser>"

with neo4j.GraphDatabase.driver(URI, auth=AUTH) as driver:
   with driver.session(database=DB) as session:
      session.run(query)

© www.soinside.com 2019 - 2024. All rights reserved.