When using removeWordsIfNoResults is it possible to retrive the words that were matched?

I want to replicate what google does when not all words are matched. I use removeWordsIfNoResults=allOptionalThey show the words that were not matched grayed out with strike through.Screenshot from 2017-11-27 12-13-57

In order to do so I need to know which words are matched and which words are not. I can only see how many words that are matched but not which ones? Can you help?

Hello Jens,

It’s not possible to do it with removeWordsIfNoResults=allOptional because in the results, you can match all the words with two different records since we consider all the words as optional to match a record.

If you use removeWordsIfNoResults=firstWords or removeWordsIfNoResults=lastWords with getRankingInfo=true, the engine returns in the attribute parsedQuery, the query with the removed words because in that case, the engine really ignored one word of the original query.

Let me know if you want more information, I’d be happy to help.

Oh that is a shame. Would be pretty simple for you guys to implement I guess? Your backend knows whats is matched and what is not. Do you have any such plans? I guess that most customers could use such a functionality.


Right, It can improve user experience, I created a feature request in our internal ticket system to track this feature request.

In meantime, you can use the matchedWords attribute of the answer for the different highlighted attributes to have the matching words per record and get this information.

Ok. Super. We will enable highlight on all searchable fields and make aunique array of words from the mathedWords arrays and diff it with the original query :slight_smile: