Justin Ziniel
03/03/2023, 10:38 PM{
"employees": [
{
"first_name": "John",
"last_name": "Doe"
},
{
"first_name": "John",
"last_name": "Smith"
}
]
}
can i search for an employee with first_name
of John
and last_name
of Smith
?Justin Ziniel
03/03/2023, 10:41 PM{
"employees": [
{
"first_name": "John",
"last_name": "Doe"
},
{
"first_name": "Jim",
"last_name": "Smith"
}
]
}
Jason Bosco
03/03/2023, 10:48 PMJustin Ziniel
03/03/2023, 10:54 PMJP Erasmus
03/04/2023, 2:16 PMfilter_by
option.
To match exactly those fields and values:
filter_by: "employees.first_name:=John && employees.last_name:=Smith"
or (no :=
)
filter_by: "employees.first_name:John && employees.last_name:Smith"
Justin Ziniel
03/06/2023, 6:23 PMJohn Smith
? (and not, say, documents with employees John Doe
and Jim Smith
)JP Erasmus
03/06/2023, 6:40 PMJustin Ziniel
03/06/2023, 7:45 PMfilter_by
syntax, and unfortunately it seems like it does not currently scope to values in the same object. IOW, it will consider the document
{
"employees": [
{
"first_name": "John",
"last_name": "Doe"
},
{
"first_name": "Jim",
"last_name": "Smith"
}
]
}
as matching the filter
filter_by: "employees.first_name:John && employees.last_name:Smith"
JP Erasmus
03/06/2023, 8:48 PMemployees.first_name: ['John', 'Jim']
employees.last_name: ['Doe', 'Smith']
JP Erasmus
03/06/2023, 8:51 PMJP Erasmus
03/06/2023, 9:11 PMJustin Ziniel
03/06/2023, 9:12 PMtypesense sub-document
to see if that was a thing 😃Jason Bosco
03/06/2023, 9:18 PMJason Bosco
03/06/2023, 9:18 PMJustin Ziniel
03/06/2023, 9:22 PMemployees.first name.value: Jim
? or employees.'first name'.value: Jim
?Jason Bosco
03/06/2023, 9:25 PMemployees.first name.value: Jim
should be fine, as long you’re using multi_search or if you’re using single-search and you’re URL encoding the spaces.
That said, we haven’t explicitly tested for field names with spaces in them in filtering, so I wouldn’t be surprised if you run into code paths where this unaccounted for and this might cause an issue… If you notice any issues, could you open a GitHub issue with a reproducible example by cloning this gistJustin Ziniel
03/07/2023, 5:05 PMJason Bosco
03/07/2023, 5:20 PM