Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to filter str with vertex in K-neighbor API (POST Version) #2693

Open
ChoelWu opened this issue Nov 12, 2024 · 1 comment
Open
Labels
api Changes of API feature New feature question Further information is requested

Comments

@ChoelWu
Copy link

ChoelWu commented Nov 12, 2024

Feature Description (功能描述)

如何根据节点字符串类型属性筛选节点,例如city属性为Hongkong
请求内容设置如下后
"label": "person",
"properties": {
"city": "P.eq('Hongkong')"
}
报错:
{
"exception": "class org.apache.hugegraph.HugeException",
"message": "Invalid value ''Hongkong'', expect a number",
"cause": "org.apache.hugegraph.HugeException: Can't read json: Unexpected character (''' (code 39)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)"'Hongkong'"; line: 1, column: 2]"
}
此外尝试了"city": "P.eq("Hongkong")" 还有 "city": "P.eq(Hongkong)",均无法筛选节点并报错

@ChoelWu ChoelWu added the feature New feature label Nov 12, 2024
Copy link

dosubot bot commented Nov 12, 2024

@ChoelWu 你好!我是Dosu,我是一个可以帮助解决错误、回答问题并成为贡献者的机器人。在等待人类维护者期间,我可以帮助你解决问题。

To filter nodes by a string property using the K-neighbor API, you should ensure that the predicate is correctly formatted in the JSON request. The correct syntax for using predicates like P.eq is to use a string representation in the format "P.method(value)". However, it seems there might be an issue with how the value is being interpreted in your JSON.

Here's how you can format your request:

{
    "label": "person",
    "properties": {
        "city": "P.eq(\"Hongkong\")"
    }
}

Make sure that the entire predicate, including the method and the value, is enclosed in double quotes. If you are still encountering errors, ensure that the JSON is correctly formatted and that the Content-Type is set to application/json in your request header to avoid any HTTP 415 Unsupported Media Type errors [1].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added api Changes of API question Further information is requested labels Nov 12, 2024
@imbajin imbajin changed the title K-neighbor API (POST, Advanced Version) 如何根据节点字符串类型属性筛选节点 [Question] How to filter str in vertex in K-neighbor API (POST Version) Nov 13, 2024
@imbajin imbajin changed the title [Question] How to filter str in vertex in K-neighbor API (POST Version) [Question] How to filter str with vertex in K-neighbor API (POST Version) Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Changes of API feature New feature question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant