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

Extract query from instant-meilisearch #952

Open
joepio opened this issue Jan 18, 2023 · 2 comments
Open

Extract query from instant-meilisearch #952

joepio opened this issue Jan 18, 2023 · 2 comments
Labels
support Question that may be answered by the support team

Comments

@joepio
Copy link

joepio commented Jan 18, 2023

Hi there! Thanks for creating and maintaining this :)

I was trying to build an export feature for my search UI, where users should be able to download all the results that they are looking at (+ the following pages included). I thought the way I could achieve this, is to extract the current Query from somewhere, and then do that search manually. That way, I can handle a larger amount of responses.

But how do I access this search query?

I can see that instantMeiliSearch creates a meilisearch client instance and calls .search at some point.

I want to call that .search manually, using a Query built from the current UI state. I'm not quite sure how to do this. I could just fetch the /search endpoint, but I still want to use my currently selected facets / values.

Some API suggestions:

  • instantMeiliSearch returns a currentQuery object, which represents the JSON body sent to the server for a search.
  • useCurrentQuery hook that does something similar?

I'm using:

    "@meilisearch/instant-meilisearch": "^0.10.1",
    "meilisearch": "^0.29.1",
    "instantsearch.js": "^4.49.1",
    "react-instantsearch-hooks-web": "^6.38.0",
@bidoubiwa bidoubiwa added the support Question that may be answered by the support team label Jan 25, 2023
@niklasfjeldberg
Copy link

Did you find this out? I am also trying to manually use .search( ), but I am unable to get facets to work. This is how I used the search, which does work.

const searchClient = instantMeiliSearch(
  config.meilisearchClient.hostUrl, // Host
  config.meilisearchClient.searchApiKey, // API key
  {
    placeholderSearch: true, // default: true.
    primaryKey: 'id' // default: undefined
  }
);

searchClient.search([{
    indexName: indexName.value,
    params: {
      // facets: ['*'],
      query: reSearchQuery.value,
      hitsPerPage: 6,
      filter: getFilters(),
      page: rePageQuery.value - 1
    }
  }])

@joepio
Copy link
Author

joepio commented Mar 1, 2023

@niklasfjeldberg sorry, haven't got this working yet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Question that may be answered by the support team
Projects
None yet
Development

No branches or pull requests

3 participants