Slackbot
08/07/2023, 1:24 PMJason Bosco
08/07/2023, 3:36 PMquery_by, along with query_by_weights determines the ranking of the best-matched recordJason Bosco
08/07/2023, 3:37 PMbut how would I display that best as a single result?
Merge all the data together in array from the results I get orIt sounds like you’re sending multiple searches in a multi_search request, with one search per field? This is not necessary to do unless you have some other constraint. Instead if you just list the fields in priority order in
query_by in a single search, Typesense will return the best matched result, across different fields in a single ranked listMichael Thomas
08/08/2023, 7:11 AMconst searchParameters = {
q: searchParams?.searchQuery,
query_by: 'title,address.city,address.county,address.state,address.street,address.zip,primaryServiceType,serviceType,servicingType',
query_by_weights: '3,2,1,1,2,2,3,3,3',
filter_by: searchParams?.filterQuery,
sort_by: sortParams.type + ':' + sortParams.order,
}
But then my results are an object that are returned following the structure I've shown above.
What I'd like to do is get a single array of best search matches, without the need to loop through all the fields in the returned object ( if that is possible )Jason Bosco
08/08/2023, 4:14 PMhit.document. You could do the filtering based on the presence of a highlight for that field in hit.highlight.
So this needs to be done client-side with the values in the API response