This message was deleted.
# community-help
s
This message was deleted.
j
You want to do
facet_by: fieldName
and
max_facet_values: 9999999
(some large number)
e
is there a way to do this with the searchClient from TypesenseInstantSearchAdapter? noticed it doesnt have the search method
j
If you’re using Instantsearch.js, you want to use the
limit
and
showMoreLimit
parameters in RefinementList or any of the other filter widgets, which the adapter then uses internally to set facet_by and max_facet_values
e
we’re using react-instantsearch
but want to have the facet refinementlist fixed with all options and not disappear as options are selected
https://typesense-community.slack.com/archives/C01P749MET0/p1690332444060009?thread_ts=1690326451.922009&cid=C01P749MET0
Could you elaborate on this? This is how I’ve seen refinementList work by default
e
yes but the default behavior is that facets with no hits wont be shown - we want to show all facets regardless
j
Ah hmm
e
with algolia we had to fetch the facets separately and pass those in with transformItems
for example: we have a category facet with a
marketing
option, if I first filter by internships then this facet option wont appear in our refinement list
j
I see, you would have to do similar with Typesense as well
The typesense-js search client can be accessed using adapter.typesenseClient
which is an instance of the typesense-js client
You should then be able to do a standard typesense search like this: https://typesense.org/docs/0.24.1/api/search.html
e
by typesenseClient do you mean SearchClient
e
ah ok yes its just not in the Type declaration
j
Ah, will add it
👍 1
Added this in
v2.7.1-3
of the adapter
e
amazing thanks!
another question: we want to be able to toggle sorting the results by date. With algolia we would conditionally change the index to a replica index sorted by date - is it similar with typesense?
j
In Typesense, a single collection (what Algolia calls an index) can be sorted on any number of fields without replica indices.
You want to configure the sort by widget this way: https://github.com/typesense/typesense-instantsearch-adapter#sortby Specifically the
items
array, in the format described in that section
e
using the SortBy component and seems to send the correct request with sort_by but doesnt seem to work - no change between default and sorted
is
_text_match:desc
default for every query? or should it be specified and somehow our default sort is already updates_date:desc
j
To be sure, are you saying that the query sent to Typesense has the correct sort_by parameter when the sortBy widget value is changed in the UI, but the results returned are not sorted by the sort_by field? If so, could you copy-as-curl the network request to Typesense for both sort orders and DM it to me?
is _text_match:desc default for every query?
If no sort_by is mentioned, yes this is default. If a sort_by is mentioned,
_text_match:desc
is added as the last sort parameter, after the sorts you’ve specified in sort_by
It looks like you have
"default_sorting_field": "updated_date"
in the collection schema. So when you don’t specify a sort_by parameter in the search, Typesense automatically sorts by
updated_date:desc
. This is why the results look similar when you add
sort_by=updated_date:desc
e
ah yes makes sense. if we set to sort by to _text_match:desc will that overwrite it
j
Yes, but only if
q
is something other than
*
, which is when text_match is calculated. Otherwise text_match is identical for a wild-card
*
query
👍 1
e
Awesome makes sense. One more thing - we are trying to get similar results that we had with algolia but it seems like the default typesense (only copied over the query_by) is having lower quality results. First half of video (localhost) is typesense, second half (simplify) is algolia. Any tips/advice on improving results (the main issue here is the 30 results from the same company in a row)
j
Could you share a screenshot of your Algolia ranking settings and also the section called “grouping and distinct” in your index configuration?
Hmm, just to be sure, are the datasets identical between what you have in your Algolia index vs Typesense collection (including the updated_date timestamps)?
e
yeah they should be pretty close currently - they were synced yesterday. As more time passes algolia will be outdated since we stopped updating
j
Are you sending that query to your Typesense Cloud cluster? Because when I search for “software” against the dataset in your cluster I see a different set of search results (you should see the same in your Typesense Cloud web console)
In any case, what’s happening here is that the word “software” being present in all the titles will result in a tie in text match score and then to break the tie, Typesense will use the default_sorting_field which in your case is updated_date, and if that also ties, then Typesense will use the document insertion timestamp to break tie, and finally the document ID
So if many job postings were updated / created at around the same time from the same company with the title “software” then they will show up next to each other
e
I see so documents that score equally with text will then use updated_date which will likely be all jobs from the same company since scraped together
j
Right
If you’re ideal ranking behavior is to only show one job posting from a single company for a given search term, you want to use
group_by: company_name
and set
group_limit: 1
e
perhaps using a different default_sorting_field would be better
its not that we want to necessarily limit company to 1 but 30 in a row is too much 😆
j
Haha! If there’s an upper limit, say 5 or 10, then group_limit and group_by would be the best way to avoid this issue completely
👍 1
e
prioritize_token_position may also be good here - have you seen many people use it to improve results
j
Yeah, I was thinking of that, but for your particular domain, I guess if someone calls a position “Software Engineer” and another position “Senior Software Engineer”, and the search term is software, token position doesn’t necessarily mean one job post is more relevant than the other
e
yes in some queries it would make sense but others may not
search is hard! haha thanks for the prompt responses with everything!
👍 1
😄 1
Is default sort order required?
j
No it’s optional
r
Is there anyway to update the
default_sorting_field
?
I think we figured out why Algolia has the different results. The default sorting mechanism is
objectId
. It seems like this isn’t possible on Typesense though
j
Is there anyway to update the default_sorting_field?
Unfortunately no. You would have to create a new collection and reindex your data in it.
👍 1
The default sorting mechanism is objectId. It seems like this isn’t possible on Typesense though
Do you let Algolia auto-generate these objectIds or do you generate them on your side?
r
Figured this was the case. We’ve setup aliases now, so upgrading the schemas is easier
Do you let Algolia auto-generate these objectIds or do you generate them on your side?
We generate the object IDs and sync them to Algolia. We’re doing the same thing with Typesense with
id
j
Ok so the equivalent in Typesense is just called
id
which is used to dedupe records. However, you can’t use the
id
field for sorting. So you would have to duplicate the same
id
in a new field called say sortId and then use that field for sorting
👍 1
r
We just set this up and now have a
posting_id
field. I think I may have misread something, but can you sort string fields? I’m running into errors when trying
j
Sorting is disabled on string fields by default (since it requires additional memory). So you would have to set
sort: true
in the schema for that field definition
👍 1
Also, string fields can only be used for sorting in sort_by, not in default_sorting_field. But you can mimic the default_sorting_field behavior, by just using sort_by explicitly in the search query
👍 1
e
Can the sort_by take multiple parameters? So for example if we want the first sort to be updated_date and the second/tiebreaker to be posting_id
r
Yeah it can
j
Yup
You can use up to 3 tie breakers in sort_by
If you need more, then you want to create a single field using any formula that weights different criteria (based on your business logic) and come up with a single weight score for each record, and then sort by that
👍 1
e
With the sort by widget what would be the format for applying multiple sort_by? Would be just be comma separated like: "jobs/sort/updated_datedesc,posting iddesc”
j
That’s correct
👍 1