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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facet values with certain characters don't work #789

Closed
mschinis opened this issue Mar 21, 2022 · 2 comments 路 Fixed by #798
Closed

Facet values with certain characters don't work #789

mschinis opened this issue Mar 21, 2022 · 2 comments 路 Fixed by #798

Comments

@mschinis
Copy link

Describe the bug 馃悰
I am currently using this library to build the requests sent to algolia, and noticed than when a value has a special character like & it is not percent encoded, leading to an incorrect query and the request failing.

If I percent encode it myself, before passing it in the library, the library then, double percent encodes it, leading to 0 results.

Culprit

.map { "\($0.name)=\($0.value?.addingPercentEncoding(withAllowedCharacters: .urlAllowed) ?? "")" }

Expected behavior 馃挱
The library should percent encode, allowing only alpha numerics instead of url allowed

@VladislavFitz
Copy link
Contributor

Hi @mschinis,
Could you give a concrete example of a parameter leading to failure?
I made a test of query with & and the url encoding works as expected.

let query = Query().set(\.query, to: "request with &")
print(query.urlEncodedString) // query=request%20with%20%26

@mschinis
Copy link
Author

Hi @VladislavFitz,

Sure, the issue I'm having is for facet values. I should have mentioned that I'm also using InstantSearchCore for building these requests like so:

        let queryBuilder = QueryBuilder(
            query: "Ostrich wall lamp",
            disjunctiveFacets: [
                // ..
            ],
            filterGroups: [ 
                FilterGroup.And(
                    filters: [
                        FacetFilter(attribute: "manufacturer", stringValue: "&Quirky")
                    ],
                    name: "manufacturer"
                )
                // ...
            ],
            hierarchicalAttributes: [
                // ..
            ],
            hierachicalFilters: [
                // ..
            ]
        )

Executing the above query, results in the following:

Screenshot 2022-03-22 at 12 50 59

After looking at this further, might be related to how InstantSearchCore is using AlgoliaSearchClient 馃

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

Successfully merging a pull request may close this issue.

2 participants