Phrase search via Searchkit? #1243
-
Hi! First of all, thank you for this absolutely fantastic project! I'm looking for a way to implement a phrase search, meaning when you search for "Hello world", I want to get only docs that have exactly this phrase. I think Algolia's instantsearch provides advancedSyntax handle (https://www.algolia.com/doc/api-reference/api-parameters/advancedSyntax/) for that. I couldn't find where (or whether) this could be turned on in SearchKit. Any help would be much appreciated! Many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Great to hear @dkalpakchi! Yes so best way is to override the default query via Sounds like you want the phase match query clause, so would expect something like const results = await apiClient.handleRequest(req.body, {
getQuery: (query, search_attributes) => {
return [
{
"multi_match" : {
"query": query,
"type": "phrase",
"fields": search_attributes
}
},
];
},
}); and you can also wrap the query with a bool so ranks docs with phrase matches but still matches on query terms. Hope this helps! Joe |
Beta Was this translation helpful? Give feedback.
Great to hear @dkalpakchi!
Yes so best way is to override the default query via
getQuery
function. You can read more about it here https://www.searchkit.co/docs/guides/customising-querySounds like you want the phase match query clause, so would expect something like
and you can also wrap the query with a bool so ranks docs with phrase matches but still matches on query terms.
Hope this helps!
Joe