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

Add support for an advanced searchbar #133

Open
Rednas83 opened this issue Aug 19, 2024 · 3 comments
Open

Add support for an advanced searchbar #133

Rednas83 opened this issue Aug 19, 2024 · 3 comments

Comments

@Rednas83
Copy link

Rednas83 commented Aug 19, 2024

@Rednas83
Copy link
Author

Rednas83 commented Aug 20, 2024

Just tried it myself. I hope it can help🤞
plugins/0.libraries.client.ts

import InstantSearch from 'vue-instantsearch/vue3/es';
export default defineNuxtPlugin(nuxtApp => {
    nuxtApp.vueApp.use(InstantSearch) 
})

pages/search.vue

<template>
  <vinput content="ClearSearchAddDelete" @input="operate"> </vinput>
  <div id="app" class="wrapper">
    <ais-instant-search :search-client="meili" index-name="movies" :future="{ preserveSharedStateOnUnmount: true }">
      <ais-search-box />
      <ais-hits>
        <template v-slot:item="{ item }">
          <ais-highlight :hit="item" attribute="name" />
        </template>
      </ais-hits>
    </ais-instant-search>
  </div>
  <pre> {{ meili }} </pre>
</template>

<script setup lang="ts">
import "instantsearch.css/themes/algolia-min.css"
const meili = useMeiliSearch("movies")
console.log("meili", meili)
// const { data } = await useFetch("/api/search/open/movies")
// console.log("/api/search/connect", data.value)
const operate = async function (event: any) {
  if (event == "Clear") {
    meili.result.value = null
  } else if (event == "Search") {
    await meili.search("Batman")
  }
}

onMounted(async () => {
  await operate("Search")
})
</script>

Nuxi info

------------------------------
- Operating System: Windows_NT
- Node Version:     v20.12.2
- Nuxt Version:     3.12.4
- CLI Version:      3.12.0
- Nitro Version:    2.9.7
- Package Manager:  [email protected]
- Builder:          -
- User Config:      telemetry, modules, meilisearch, experimental, nitro, icon, build, routeRules, components, content, formkit, imports, css, devtools, compatibilityDate
- Runtime Modules:  @vueuse/[email protected], @nuxt/[email protected], normalizedModule(), @nuxt/[email protected], @formkit/[email protected], @nuxt/[email protected], @nuxt/[email protected], [email protected], [email protected]
- Build Modules:    -
------------------------------

But I get
Client
image
Server
image
Meili
image

Looks like ais-instant-search requires more then just the result and the read function which are returned from useMeiliSearch("movies"). Also for me it's strange that the server is giving warnings about a page but perhaps that is an issue with nuxt🤔

Any ideas what is missing or how to get it to work?

@xlanex6
Copy link
Owner

xlanex6 commented Aug 28, 2024

Hi @Rednas83

I was off for a couple of days

I will investigate and try to get back to you with feedback

@Rednas83
Copy link
Author

Rednas83 commented Oct 9, 2024

Any updates?

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

2 participants