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

Prefix Query Not Encoding Case-Insensitive #1546

Closed
crweatherly opened this issue Nov 3, 2021 · 3 comments
Closed

Prefix Query Not Encoding Case-Insensitive #1546

crweatherly opened this issue Nov 3, 2021 · 3 comments
Assignees
Labels
Milestone

Comments

@crweatherly
Copy link

Please use the following questions as a guideline to help me answer
your issue/question without further inquiry. Thank you.

Which version of Elastic are you using?

[x] elastic.v7 (for Elasticsearch 7.x)
[ ] elastic.v6 (for Elasticsearch 6.x)
[ ] elastic.v5 (for Elasticsearch 5.x)
[ ] elastic.v3 (for Elasticsearch 2.x)
[ ] elastic.v2 (for Elasticsearch 1.x)

Please describe the expected behavior

NewPrefixQuery("foo", "bar").CaseInsensitive(true)

should yield:

{
  "prefix": {
    "foo": {
      "case_insensitive": true, "value": "bar"
    }
  }
}

Please describe the actual behavior

NewPrefixQuery("foo", "bar").CaseInsensitive(true)

yields:

{
  "prefix": {
    "foo": "bar"
  }
}

PrefixQuery.Source() fails to check if the case-insensitive property has been set before defaulting to generating the short request form:

--- a/search_queries_prefix.go
+++ b/search_queries_prefix.go
@@ -52,7 +52,7 @@ func (q *PrefixQuery) Source() (interface{}, error) {
        query := make(map[string]interface{})
        source["prefix"] = query

-       if q.boost == nil && q.rewrite == "" && q.queryName == "" {
+       if q.boost == nil && q.rewrite == "" && q.caseInsensitive == nil && q.queryName == "" {
                query[q.name] = q.prefix
        } else {
                subQuery := make(map[string]interface{})

Any steps to reproduce the behavior?

Set the CaseInsensitive() property of PrefixQuery and no other optional properties.

@olivere olivere added the bug label Dec 9, 2021
@olivere olivere self-assigned this Dec 9, 2021
@olivere olivere modified the milestones: 7.x, 7.0.30 Dec 9, 2021
@olivere
Copy link
Owner

olivere commented Dec 9, 2021

Thanks for reporting. Will fix it in the next release.

@martinrode
Copy link

NewWildcardQuery is missing "CaseInsensitive". Maybe this can be added everywhere where Elastic allowes "case_insensitive" (since 7.10.0)?

@olivere
Copy link
Owner

olivere commented Dec 17, 2021

@martinrode WildcardQuery already has CaseSensitive in 7.0.29. Will look for the other cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants