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

filter_by with facet string data is returning empty #54

Closed
melovv opened this issue Apr 21, 2019 · 1 comment · Fixed by #55
Closed

filter_by with facet string data is returning empty #54

melovv opened this issue Apr 21, 2019 · 1 comment · Fixed by #55
Labels

Comments

@melovv
Copy link

melovv commented Apr 21, 2019

Hi.

I'm experimenting typesense but I'm getting an unexpected behaviour.

Best,

Vinícius.

Description

Using the companies example, a query with filter_by country is returning empty if the field is facet. Is this the expected behavior?

Steps to reproduce

Companies example taken from here: https://typesense.org/0.9.2/api/

Query using filter_by:
localhost:8108/collections/companies/documents/search?q=stark&query_by=company_name&filter_by=country:USA

Expected Behavior

{"facet_counts":[1],"found":1,"hits":[{"document":{"company_name":"Stark Industries","country":"USA","id":"124","num_employees":5215},"highlights":[{"field":"company_name","snippet":"Stark Industries"}],"seq_id":0}],"page":1,"search_time_ms":0}

Actual Behavior

{"found":0,"hits":[],"page":1,"search_time_ms":0}

Metadata

Typsense Version: 0.92

OS: macOS 10.12.6

@kishorenc
Copy link
Member

@melovv

Thank you for creating this issue.

Faceted fields are indexed verbatim without any "normalization". So, the value USA is indexed as it is.

However, when a filter_by is performed on a string field, Typesense "normalizes" the string before searching for it. So, Typesense looks for usa (the normalized version of USA) and is not able to find the document. I'm going to call this a bug. Ideally, when a facet field is filtered upon, we should search verbatim instead of normalizing the filter_by value.

For now, as a work-around, you can create another string field that has a facet: false and filter on that.

@kishorenc kishorenc added the bug label Apr 22, 2019
kishorenc added a commit that referenced this issue Apr 22, 2019
…d of normalizing the filter_by value.

There was also a difference in the behavior between string and string array facet fields which is corrected in this PR.

Fixes #54
kishorenc added a commit that referenced this issue Jun 4, 2022
…d of normalizing the filter_by value.

There was also a difference in the behavior between string and string array facet fields which is corrected in this PR.

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

Successfully merging a pull request may close this issue.

2 participants