Any thoughts on how to support multiple collection...
# community-help
r
Any thoughts on how to support multiple collection searches with
react-instantsearch
? I have two collections that I would like to combine results for. They have different fields in each collection though. Do I need to do some kind of overriding of the
react-instantsearch-hooks-web
to support federated multisearch? Any ideas on where I would want to inject in this call? I see support for this was built into the typesense react instant search adapter but I don't see any documentation on how to make a federated search possible. Is there documentation I can look at or could someone perhaps point me in the right direction?
I see this comment here but I can't seem to click into the instructions on how to delineate the specific query_by... https://github.com/typesense/typesense-instantsearch-adapter/issues/38#issuecomment-823752445
Ok I think I'm figuring it out:
Copy code
// Search parameters that are common to all collections/indices go here:
  additionalSearchParameters: {
    query_by: "",
  },
  // Search parameters that need to be *overridden* on a per-collection-basis go here:
  collectionSpecificSearchParameters: {
    snippets: {
      query_by: "answer,name",
      query_by_weights: "2,1",
    },
    searchable: {
      query_by: "text,context",
      query_by_weights: "2,1",
    },
  },
Now I'm working out some of the kinks in having multiple
Index
within the
InstantSearch
I'm getting undefined for highlight results weirdly...
When the matchLevel is full the value is undefined for all highlight fields in multi / federated search. When I do normal query by I don't have any issue with highlight results
j
collectionSpecificSearchParameters
is the way to go. The undefined behavior sounds strange. Could you try using the latest version of the instantsearch adapter and at least Typesense 0.23.1 to see if you can replicate the issue?
If you can still replicate it, this could be a bug in the adapter. Could you open a Github issue with a minimal example where I can replicate the issue locally? I can then debug it
r
Perhaps its becaues my cluster is on v0.23.0 and i'm using latest libraries. Waiting to upgrade my cloud cluster. Gonan try testing on a local cluster
j
I saw your upgrade request come through. Happy to queue it up now if you’d like. Let me know
r
That'd be great 🙂
👍 1
j
You’re all set.
I doubt this is an issue on the Typesense server side, since you were already running a pretty recent version, but let’s see!
r
Thanks! Your hypothesis is right tho 🙂 Gonna put together a small sandbox to replicate issue. Is there a public cloud instance to test against in the sandbox? I can just leave creds empty for it
j
Yeah you can leave the creds empty
r
j
Would you be ok if we accessed the data in your cluster to debug this issue? (Need your explicit permission before we access user data)
r
For sure
👍 1
Just a testing cluster rn so no PII data
👍 1
j
Ah I see what’s going on. It looks like you’re using the
<Highlight />
component. By default Typesense snippets results. So when you use
<Highlight />
, the field it’s looking for doesn’t exist in the Typesense response and it displays as undefined. If you add a param called
highlight_full_fields
like below, you should then start seeing the highlights instead of undefined.
Copy code
collectionSpecificSearchParameters: {
    snippets: {
      query_by: "answer,name",
      query_by_weights: "2,1",
      highlight_full_fields: "answer,name",
    },
    searchable: {
      query_by: "text,context",
      query_by_weights: "2,1",
      highlight_full_fields: "text,context",
    }
  }
r
Jesus y'all might be faster than me at debugging and I don't say that lightly
j
Hahaha! 😄
r
So when I did just a single index it highlighted fine which was why I didn't even consider it was a configuration thing
I guess on the default
query_by
setup highlight full fields is set?
j
That is strange to hear though… I’m surprised it worked for a single index
Oh hmm!
https://typesense-community.slack.com/archives/C01P749MET0/p1659570739816799?thread_ts=1659561876.263559&amp;cid=C01P749MET0 I just double-checked the adapter code. We don’t set a default for highlight full fields
r
so weird. snippets work as expected as well (in federated search and
query_by
). strange edge case
j
Yup,
<Snippet />
will work by default, since Typesense snippets all query_by fields without additional configuration