typesense / typesense-instantsearch-adapter

A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js
MIT License
414 stars 64 forks source link

Is there a way to access the text_match score under the transformItems() when using Instantsearch + Typesense adapter #56

Closed junelmujar closed 3 years ago

junelmujar commented 3 years ago

Hello!

I would like to know if this if there a way to access the text_match score under the transformItems() when using Instantsearch + Typesense adapter. The purpose of this to do additional client side sorting on the results. I can see in the returned XHR result that the text_match score is returned + document fields and values. If I do console.log(items) under the transformItems() function, there is no text_match score.

Sample code below.

instantsearch.widgets.hits({
    container: '#hits',
    transformItems(items) {
        items.map(function(item) {
            console.log(item.text_match); // returns undefined
        });
    }
});

Additional info:

Typsense Cloud Beta Client: Instantsearch.js + Instantsearch Typesense adapter

jasonbosco commented 3 years ago

@junelmujar I just published v1.2.2-0 that adds text_match to all the results. Could you let me know if that works?

junelmujar commented 3 years ago

Hi @jasonbosco. Thanks for this mate.

I tried it today and I got this error: Uncaught ReferenceError: TypesenseInstantsearchAdapter is not defined...

I also got the same error yesterday when I did my own build of the library with my changes.


I'm using this version of instantsearch btw:

jasonbosco commented 3 years ago

Looks like there's a typo - the S in InstantSearch needs to capitalized. So you want to do new TypesenseInstantSearchAdapter

junelmujar commented 3 years ago

Confirming that it's working now. Thanks a lot @jasonbosco 👍