Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 ability to use the core logic in a standalone way #1231

Open
JoelPintoRibeiro opened this issue Mar 6, 2023 · 3 comments
Open

V4 ability to use the core logic in a standalone way #1231

JoelPintoRibeiro opened this issue Mar 6, 2023 · 3 comments

Comments

@JoelPintoRibeiro
Copy link

The problem

With the V3 version, we can use the @searchkit/sdk to create custom filters and trigger searches manually.

With the V4 version, it seems we have less control over the actions performed, and in the UI, it's mainly tied to other frameworks like InstantSearch for triggering the search.

Environment

  • Searchkit version (or git revision) that exhibits the issue: 4.x
  • Last Searchkit version that did not exhibit the issue : 3.x

Details

In our use case, we would like to create a wrapper around the searchkit library:
We have a big search screen with many filters that can be boolean, numeric, range, prefix, or exact match and that, in the end, can generate a complex query including many OR and AND operators.

We don't use facets, so in our case, that's not a requirement.

But in my first attempt at using the V4 version, I didn't find how I could have control over the pagination, trigger searches, or modify filters on the fly.

In a perfect world, we would love to have a kind of "searchkit/core" that we can interact with to trigger search, customize the query/filter parameters, and generate the output query depending on our needs (prefix, match, multi, etc.).

I hope I was clear enough; otherwise, I can provide more details!

Thanks for the support ! :)

@joemcelroy
Copy link
Member

Thanks for the issue! Will come back over thoughts.

@ColeDCrawford
Copy link
Contributor

Would love to hear thoughts on this, being able to trigger searches manually and some of these other actions would be great

@joemcelroy
Copy link
Member

Hey so haven't progressed further on this but its worth noting that you can also use algolia's JS helper too, which is a high level client. https://community.algolia.com/algoliasearch-helper-js/

I will document this more in docs if this sounds like a good outcome.

A future will look like a proper Searchkit client, very similar to algolia's JS helper.

import Client from '@searchkit/instantsearch-client'

const sk = new Searchkit({
  connection: {
    host: 'http://localhost:9200',
    auth: {
      username: "elastic",
      password: "changeme"
    }
  },
  search_settings: {
    search_attributes: [{ field: 'title', weight: 3 }, 'actors', 'plot'],
    result_attributes: ['title', 'actors', 'poster', 'plot'],
    highlight_attributes: ['title'],
    facet_attributes: [
      { attribute: 'actors', field: 'actors.keyword', type: 'string' },
      { attribute: 'imdbrating', type: 'numeric', field: 'imdbrating' }
    ]
  }
})

const searchClient = Client(sk);

var helper = algoliasearchHelper(searchClient, 'imdb_movies', {
  facets: ['imdbrating'],
  disjunctiveFacets: ['actors']
});
helper.on('result', function(event) {
  console.log(event.results);
});
helper
  .toggleFacetRefinement('actors', 'arnold schwarzenegger')
  .search();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants