Issue with Optional Filtering and Id Field
TLDR Stefan encounters a bug with optional filtering on the id field, where _eval sort criteria doesn't show expected results. Kishore Nallan confirms it might be a bug. An issue is created on GitHub.
Mar 13, 2023 (7 months ago)
Stefan
01:51 PMI am having an issue with the new optional filtering, I would expect that if I put the "_eval" sort criteria first that documents that match this expressions are shown first no matter the other sort criteria, but that doesn't seem to be the case:
---------- Search parameters
{'q': '*', 'query_by': 'name', 'sort_by': '_eval(id:1):asc,pop:desc'}
---------- Query output
{'facet_counts': [],
'found': 2,
'hits': [{'document': {'id': '0', 'name': 'a', 'pop': 1},
'highlight': {},
'highlights': []},
{'document': {'id': '1', 'name': 'b', 'pop': 0},
'highlight': {},
'highlights': []}],
'out_of': 2,
'page': 1,
'request_params': {'collection_name': 'test_collection',
'per_page': 10,
'q': '*'},
'search_cutoff': False,
'search_time_ms': 0}
So in the case above I'd expect name: 'b' to be the first document, because it matches the _eval() condition, and 'a' the second, but that doesn't seem to be the case.
Am I misunderstanding the feature? Changing _eval(xxx):asc to desc doesn't change the output.
I made a little reproduction repo so you can see the exact configuration: https://github.com/reinoldus/typesense-reproduction-repo
Kishore Nallan
01:53 PMStefan
01:56 PMStefan
01:58 PM---------- Search parameters
{'q': '*',
'query_by': 'name',
'sort_by': '_eval(other_field:test):desc,pop:desc'}
---------- Query output
{'facet_counts': [],
'found': 2,
'hits': [{'document': {'id': '1',
'name': 'b',
'other_field': 'test',
'pop': 0},
'highlight': {},
'highlights': []},
{'document': {'id': '0',
'name': 'a',
'other_field': 'not_test',
'pop': 1},
'highlight': {},
'highlights': []}],
'out_of': 2,
'page': 1,
'request_params': {'collection_name': 'test_collection',
'per_page': 10,
'q': '*'},
'search_cutoff': False,
'search_time_ms': 0}
Kishore Nallan
01:59 PMStefan
02:06 PMKishore Nallan
02:19 PMStefan
02:24 PMTypesense
Indexed 2779 threads (79% resolved)
Similar Threads
Fixing Multiple Document Retrieval in Typesense
Phil needed an efficient way to retrieve multiple documents by id. Kishore Nallan proposed a solution available in a pre-release build. After some bug fixing regarding id matching by Jason and Kishore Nallan, Phil successfully tested the solution.
Methods for Fetching, Querying, and Modifying Collections in Typesense
Bill inquired about performing OR queries, querying empty arrays and modifying collections in Typesense. Kishore Nallan explained the current limitations and provided workarounds and recommendations for each case. The conversation also touched upon the usage of cache in Typesense and the workings of the _eval function.
Threading Problem During Multiple Collection Creation and Batch Insertion in Typesense
Johan has a problem with creating multiple collections and batch-inserting documents into Typesense, which is returning results from different collections. Kishore Nallan helps troubleshoot the issue and suggests a potential local race condition, which is fixed in a later build.
Troubleshooting Typo Highlighting in Search Queries
Stefan queried "chews" and "Roche", despite having a typo distance of 4, was highlighted. Kishore Nallan requested to test on v0.20 RC. Random results like "Sachets" and "Lachesca" were also highlighted. On single record query, highlighting works. Kishore Nallan assured to address this issue in the pending release.
Phrase Search Relevancy and Weights Fix
Jan reported an issue with phrase search relevancy using Typesense Instantsearch Adapter. The problem occurred when searching phrases with double quotes. The team identified the issue to be related to weights and implemented a fix, improving the search results.