Hi, Just want to ask on what should be the expecte...
# community-help
c
Hi, Just want to ask on what should be the expected results of these filters:
user_id
and
user_id_b
are integer fields and from my understanding, they should return same results? that is excluding documents if at least one of them is equal to 1 1.
user_id:!=1 && user_id_b:!=1
2.
user_id:!=[1] && user_id_b:!=[1]
h
This filter would only exclude documents where both
user_id
and
user_id_b
are not 1.
c
@Harpreet Sangar it's a negation filter, I think it will return documents where both
user_id
and
user_id_b
are not 1, right? e.g Document A: {user_id: 1, user_id_b: 2} Document B: {user_id: 1, user_id_b: 1} Document C: {user_id: 3, user_id_b: 2} Using those filters, it will return C only, right?
h
Yeah just realised that. If either `user_id`/`user_id_b` is
1
in the document, it won't be returned.
c
@Harpreet Sangar got it, but on our application, the first 1 (without array), returns no hits, the other one (with array), works as expected, just want to confirm if my understanding is correct
h
There shouldn't be any difference 🤔
c
that's what I thought, I tried many times with different values, and always, the one WITHOUT array does not return anything
h
Is there a difference between the result of
user_id:!=1
and
user_id:!=[1]
too?
c
that one I haven't tried yet, always have the && condition, will check
👍🏼 1
@Harpreet Sangar still the same
user_id:!=1
does not return any hits
h
How many docs does
user_id:!=[1]
return?
c
sample response
Copy code
..., {'document': {'id': '34568'}, 'highlight': {}, 'highlights': []}, {'document': {'id': '34466'}, 'highlight': {}, 'highlights': []}], 'out_of': 3692, 'page': 1, 'request_params': {'collection_name': 'forsale_development', 'first_q': '*', 'per_page': 15, 'q': '*'}, 'search_cutoff': False, 'search_time_ms': 13}
Copy code
'found': 591,
1
h
With
user_id:!=1
found is 0?
c
yes
👀 1
this is the full
filter_by
Copy code
"(uploader_is_active: true || contact_is_active: true) && status_id:1 && (shared_future_updated_at:<=1477756652.0 && shared_future_organizations:=['ALL', 'C1', 'T1', 'C1T1', 'CL7', 'CL7C1'] || shared_organization_ids:=[68]) && (uploader_organization_id:!=[1])"
if I change the
uploader_organization_id:!=[1]
to
uploader_organization_id:!=1
, it wont return anything
h
You were able to reproduce this issue with only
uploader_organization_id:!=1
filter, right?
Can you provide the schema definition of this field?
c
i did, but let me try again just to be sure
@Harpreet Sangar tried again using only
'filter_by': 'uploader_organization_id:!=1'
, still the same
h
Okay. Please provide the definition of this field.
c
I was told to raise an issue on this https://github.com/typesense/typesense/issues/1871
1
i've attached the schema there with sample records
@Harpreet Sangar
Copy code
{
            "facet": false,
            "index": true,
            "infix": false,
            "locale": "",
            "name": "uploader_organization_id",
            "optional": true,
            "sort": false,
            "stem": false,
            "store": true,
            "type": "int32"
        },
h
Thanks, I'll take a look.
c
Thank you, appreciate it
@Harpreet Sangar might help, full search parameters
Copy code
[{'collection': 'forsale_development', 'q': '*', 'filter_by': 'uploader_organization_id:!=1', 'include_fields': 'id', 'per_page': 15, 'page': 1, 'prefix': False, 'max_facet_values': 500, 'facet_strategy': 'top_values', 'sort_by': 'validated_at:desc', 'facet_by': 'country_ids, sector_ids, customer_type_ids, equity_stake_ids, selling_reason_ids, contact_cluster_ids'}]
h
I've figured out the bug
uploader_organization_id: [!=1]
also produces 0 results
c
@Harpreet Sangar bug for both?
:!=1
and
:!=[1]
h
:!=[1]
works fine.
[!=1]
and
:!=1
do not.
c
[!=1]
what does this filter do?
not aware that this is possible
don't see in documentation
h
You can apply individual comparators in a multi-value filter like,
[>=50, !=30, <50]
c
i see, that's nice
h
Yeah, there's room for improvement in the docs.