Kevin
01/14/2025, 10:32 PMinput_array = ["shrimp", "bread", "oil", "salt", "pepper]
document that should match:
{
"title": "recipe0",
"ingredients": [
{
"id": 0,
"name": "shrimp"
},
{
"id": 1,
"name": "oil"
}
]
}
document that should NOT match (because "tomato" is not in input_array):
{
"title": "recipe1",
"ingredients": [
{
"id": 0,
"name": "shrimp"
},
{
"id": 1,
"name": "oil"
},
{
"id": 2,
"name": "tomato"
}
]
}
Anyone know a way to do this?
Thanks a lot!Jason Bosco
01/15/2025, 12:10 AMJason Bosco
01/15/2025, 12:10 AMstring
field and then set drop_tokens_threshold: 0
when doing the searchKevin
01/15/2025, 1:42 AMKevin
01/15/2025, 1:50 AMJason Bosco
01/15/2025, 2:49 AMChicken (bone-in)
in a single string field, then searching for "chicken" will fetch itJason Bosco
01/15/2025, 2:50 AMKevin
01/15/2025, 2:55 AMcontains
or contains_all
query?Jason Bosco
01/15/2025, 2:56 AMcontains
is the default mode of operation in Typesense.
contains_all
is what happens when you set drop_tokens_threshold: 0
Jason Bosco
01/15/2025, 2:57 AMKevin
01/15/2025, 3:04 AMLionel Ovaert
01/15/2025, 9:57 AMFiltering Arrays:
filter_by can be used with array fields as well.
For eg: If genres is a string[] field:
- genres:=[Rock, Pop] will return documents where the genres array field contains Rock OR Pop.
So in your case ingredients:=input_array
would return all documents where one of the elements of input_array is in the ingredient listKevin
01/15/2025, 6:06 PMKevin
01/15/2025, 9:04 PMis_subset
query or plans to implement one? https://stackoverflow.com/questions/16109351/find-documents-in-mongodb-whose-with-an-array-field-is-a-subset-of-a-query-array