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

[Bug]: Query failed with double quotes #28365

Closed
1 task done
baiyuelanshan opened this issue Nov 13, 2023 · 16 comments
Closed
1 task done

[Bug]: Query failed with double quotes #28365

baiyuelanshan opened this issue Nov 13, 2023 · 16 comments
Assignees
Labels
kind/bug Issues or changes related a bug triage/accepted Indicates an issue or PR is ready to be actively worked on.
Milestone

Comments

@baiyuelanshan
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Environment

- Milvus version:2.2.9
- Deployment mode(standalone or cluster):standalone
- MQ type(rocksmq, pulsar or kafka): rocksmq
- SDK version(e.g. pymilvus v2.0.0rc2): milvus-sdk-java 2.2.9
- OS(Ubuntu or CentOS): CentOS
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

when I used scalar filtering on a varchar fieldd with double quotes, I met an expression error:

Error: failed to create query plan: cannot parse expression: tag == "A "test"", error: invalid expression: tag == "A "test"" 

code for setting the expression:
searchParam = builder.withExpr("tag == "A "test""").build();

Expected Behavior

No response

Steps To Reproduce

No response

Milvus Log

No response

Anything else?

No response

@baiyuelanshan baiyuelanshan added kind/bug Issues or changes related a bug needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 13, 2023
@xiaofan-luan
Copy link
Collaborator

you have to do it like 'A "test"' or you have to use Escape character

@yanliang567
Copy link
Contributor

/assign @baiyuelanshan
please retry as comments above.

/unassign

@yanliang567 yanliang567 added help wanted Extra attention is needed and removed kind/bug Issues or changes related a bug needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 14, 2023
@baiyuelanshan
Copy link
Author

acctually, I have use Escape charater, but the text editor didn't display it .
milvus_code
milvus_error

@xiaofan-luan
Copy link
Collaborator

@yanliang567
could you try on 2.2.9 and latest 2.3.3?

@yanliang567
Copy link
Contributor

/assign @NicoYuan1986

@yanliang567 yanliang567 added triage/needs-information Indicates an issue needs more information in order to work on it. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed help wanted Extra attention is needed labels Nov 14, 2023
@NicoYuan1986
Copy link
Contributor

Reproduced on v2.2.9 and master-latest. Needs repair. @yanliang567

@xiaofan-luan
Copy link
Collaborator

/assign @xiaocai2333
could you help on it

@xiaofan-luan
Copy link
Collaborator

@NicoYuan1986
is this reproducible on python sdk also?

@NicoYuan1986
Copy link
Contributor

@NicoYuan1986 is this reproducible on python sdk also?

Yes.
milvus v2.2.9, I use pymilvus==2.2.9
milvus master-latest, I use pymilvus==2.3.3
I think it's related

@xiaocai2333
Copy link
Contributor

xiaocai2333 commented Nov 14, 2023

@baiyuelanshan If your expression contains a string, the string must be enclosed in double quotes or single quotes. You can try this:

.withExpr("question == \"A \\\"test\\\"\"")

@NicoYuan1986
Copy link
Contributor

if insert "A "test"" or 'A "test"', can search with expr="tag == "A \"test\"""
if insert "A 'test'", can search with expr="tag == "A 'test'""

@yanliang567 yanliang567 added kind/bug Issues or changes related a bug and removed triage/needs-information Indicates an issue needs more information in order to work on it. labels Nov 15, 2023
@yanliang567 yanliang567 added this to the 2.3.4 milestone Nov 15, 2023
@chenxin6
Copy link

if insert "A "test"" or 'A "test"', can search with expr="tag == "A "test""" if insert "A 'test'", can search with expr="tag == "A 'test'""

I have inserted a string like A "test" B. But I can't search this data by using the expr tag == "A \"test\" B".

@xiaocai2333
Copy link
Contributor

if insert "A "test"" or 'A "test"', can search with expr="tag == "A "test""" if insert "A 'test'", can search with expr="tag == "A 'test'""

I have inserted a string like A "test" B. But I can't search this data by using the expr tag == "A \"test\" B".

Thank you for bringing up this issue. Our handling of escaped characters in strings wasn't very robust previously. We plan to address this in a future release.
And recommend avoiding escaped characters in the meantime when using the current version.

sre-ci-robot pushed a commit that referenced this issue Nov 23, 2023
master pr: #28416 
issue: #28365
Fix bug for parsing error when a string enclosed in single quotes in an
expression contains multiple double quotes.
such as:
```
expr = "tag == '\"blue\"'"
```

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
sre-ci-robot pushed a commit that referenced this issue Nov 23, 2023
issue: #28365 
Fix bug for parsing error when a string enclosed in single quotes in an
expression contains multiple double quotes.
such as:
```
expr = "tag == '\"blue\"'"
```

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
sre-ci-robot pushed a commit that referenced this issue Nov 24, 2023
master pr: #28416 
issue: #28365
Fix bug for parsing error when a string enclosed in single quotes in an
expression contains multiple double quotes.
such as:
```
expr = "tag == '\"blue\"'"
```

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
sre-ci-robot pushed a commit that referenced this issue Nov 29, 2023
1. modify test cases about output a non-existed field. issue: #28465
2. add cases about creating collection using different language
3. add test case about inserting a string value to a pk(int64) field
4. add test case about search with expression using double quotes.
issue: #28365

Signed-off-by: nico <cheng.yuan@zilliz.com>
@yanliang567
Copy link
Contributor

@xiaocai2333 @NicoYuan1986 can we close this issue now?

@xiaocai2333
Copy link
Contributor

@xiaocai2333 @NicoYuan1986 can we close this issue now?

I think it has been fixed.
@NicoYuan1986 please verify it.

@NicoYuan1986
Copy link
Contributor

@xiaocai2333 @NicoYuan1986 can we close this issue now?

I think it has been fixed. @NicoYuan1986 please verify it.

Test case test_search_expression_with_double_quotes has been added. And it performs well in nightly tests.
So close the issue now. version: master-20240111-930735c4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Issues or changes related a bug triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

6 participants