Skip to content

Phrase search via Searchkit? #1243

Answered by joemcelroy
dkalpakchi asked this question in Q&A
Discussion options

You must be logged in to vote

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-query

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

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dkalpakchi
Comment options

Answer selected by dkalpakchi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants