#community-help

Inconsistent "found" and "hits" values with object sorting

TLDR Michael is experiencing inconsistency between "found" and "hits" values when using object sorting. Kishore Nallan attributes the issue to a possible bug and asks for the dataset to investigate further.

Powered by Struct AI
May 17, 2023 (7 months ago)
Michael
Photo of md5-0cab3a3dbc3934c73e95b7a427d8934e
Michael
12:21 PM
Hi everyone. Just wondering whether anyone knows why objects are not allowed to be created with the "sort": true flag? I ask because the default value of autmatically indexed fields within an object appears to be true for int64 but false for string. Ideally I need it to be true for both or I see inconsistent behaviour when querying the data.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:18 PM
String sorting requires an index which is quite memory intensive so we don't enable that by default.
Michael
Photo of md5-0cab3a3dbc3934c73e95b7a427d8934e
Michael
01:38 PM
Thanks for the reply. The reason I ask the question is that I have a query like the following
01:38
Michael
01:38 PM
/search?q=*&query_by=title,description&filter_by=attributes.make.name:[john-deere]&sort_by=created_at:desc&per_page=24&page=1
01:39
Michael
01:39 PM
Which returns a value for found but not for hits

{
"facet_counts": [],
"found": 43,
"hits": [],
"out_of": 1269,
01:40
Michael
01:40 PM
Whereas if i specify some text
search?q=tractor&query_by=title,description&filter_by=attributes.make.name:[john-deere]&sort_by=created_at:desc&per_page=24&page=1

I get both hits and found
{
"facet_counts": [],
"found": 2,
"hits": [
{
"document": {
"attributes": {
01:41
Michael
01:41 PM
If I change sort: true the issue goes away, but I guess if that's there for the memory consumption reason, maybe I should structure my query differently?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:32 PM
Hmm that sounds like a bug. Are you able to reproduce the issue reliably? And how big is the dataset?
02:33
Kishore Nallan
02:33 PM
Hits array should not be empty when found is not zero.
Michael
Photo of md5-0cab3a3dbc3934c73e95b7a427d8934e
Michael
02:53 PM
Dataset is pretty small <1500 records. Can reproduce every time.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:54 PM
Would you be able to share it with us?
Michael
Photo of md5-0cab3a3dbc3934c73e95b7a427d8934e
Michael
02:59 PM
Just messaged you privately

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3005 threads (79% resolved)

Join Our Community

Similar Threads

Resolving Typesense Result Issue in Document Collection Queries

Mike was encountering errors when searching for specific query in their Typesense document collection. Jason suggested it may be due to the `drop_tokens_threshold` setting. There was a misunderstanding but after further explanation from Jason, Mike understood and decided to continue the conversation via email.

1

19
21mo

Querying with Typesense-Js and Handling Null Values

michtio was querying using typesense-js and receiving fewer results than expected. Kishore Nallan suggested using different query parameters. Further discussion led to the handling of 'null' values and filtering syntax in the search queries. The thread ended with Jason offering migration support from Algolia to Typesense.

4

39
17mo
Solved

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.

6

111
8mo
Solved

Improving System Performance and Typesense Query Efficiency

SamHendley was experiencing performance issues with Typesense's large-scale system testing and proposed several improvements. Both Jason and Kishore Nallan addressed the suggestions and corrected some misconceptions. They provided further clarification and recommended upgrades for better performance.

9
12mo

Issues Sorting Multiple Fields with Sort_by in Typesense Query

Rishabh was having trouble sorting two fields separately with a single query. Jason explained that a secondary sorting will only occur if the first sort results in matching values. They clarified the functionality of sorting in various search engines.

3

34
34mo