Mingyuan (Jasper) Li
11/25/2024, 10:33 PMfilterBy
, and filterBy looks like: metric1:=[TYPE_A,TYPE_B,TYPE_C,TYPE_D] && metric2:!=[VALUE_1,VALUE_2,VALUE_3] && metric3:>0 && metric4:<0.99 && (metric5:>10000 || metric1:=TYPE_D) && (metric6:>100000 && (metric1:=TYPE_D || metric6:>1000)) && (metric1:!='TYPE_A' || metric7:true || metric8:true)
, basically we have many filters and each filter contributes 300ms - 600ms and overall it's 2.3s.Jason Bosco
11/25/2024, 11:40 PM:=
to :
if those fields only have values with a single word without spaces.
You also want to set range_index: true
in the schema definition for any fields that you use with the > or < operatorsMingyuan (Jasper) Li
11/26/2024, 1:37 AMMingyuan (Jasper) Li
11/26/2024, 2:24 AMJason Bosco
11/26/2024, 5:37 AMJason Bosco
11/26/2024, 5:37 AMFanis Tharropoulos
11/26/2024, 9:19 AMexport interface CollectionFieldSchema {
name: string;
type: FieldType;
optional?: boolean;
facet?: boolean;
index?: boolean;
sort?: boolean;
locale?: string;
infix?: boolean;
stem?: boolean;
num_dim?: number;
store?: boolean;
range_index?: boolean; // even if missing the next one will take care of it
[t: string]: unknown; // this just says that it's a Record<string, unknown>, so anything with a key of string goes
}
Mingyuan (Jasper) Li
11/26/2024, 4:49 PMrange_index
indeed brings down the query time by 80%! I'll try to do this for our prod schema.