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

Basic Issue - Setup #14

Closed
cartoonmadrasah opened this issue Dec 29, 2019 · 9 comments
Closed

Basic Issue - Setup #14

cartoonmadrasah opened this issue Dec 29, 2019 · 9 comments
Assignees

Comments

@cartoonmadrasah
Copy link

I am not being able to generate any search results, I wonder what am I doing wrong here. Here is my setup. Kindly help. Thank you.

Image 1

Image 2

Image 3

Thank you once again.

@travis-r6s
Copy link
Owner

Hello @cartoonmadrasah

Do you possibly have a repo I could look at? If not, would you be able to show me the output of a query using that type? I.e.

query {
  predubai (id: something) {
    Id
    Emirate
    ...etc
  }
}

Those search fields look as if they may be custom object types, rather than strings/IDs etc?

@travis-r6s travis-r6s self-assigned this Dec 29, 2019
@cartoonmadrasah
Copy link
Author

Image 4

@travis-r6s
Copy link
Owner

travis-r6s commented Dec 30, 2019

Yes, as I thought, those fields are actually objects - in your server file could you do emirate: Item.emirate['_text'] for each field, so when you query emirate it will be a string? Then flexsearch should be able to index it.

@cartoonmadrasah
Copy link
Author

cartoonmadrasah commented Dec 31, 2019

I tried with the ID field. That did not work. I also tested it with one field using the method you suggested (company_name). It also did not work.

I followed the instructions as they were given but now I have basic question maybe that do I need to also import the library in the main.js or just by calling it on the gridsome.config.js sufficient.

Kindly give me your email id so that I may add you to the repository.

@travis-r6s
Copy link
Owner

@cartoonmadrasah please use travis@travisreynolds.dev

The plugin will automatically configure the client for you, so you should just be able to use this.$search in your code (or import the included mixin).

@cartoonmadrasah
Copy link
Author

I have added you to the repo.

@travis-r6s
Copy link
Owner

@cartoonmadrasah Just had a look at that repo, and it all seems to work?
image

searching for the ID won't work, as you need at least 3 characters to start searching... if (searchTerm.length < 3) return [] but searching for the company name should work.
Results won't show up in Search.vue, as you are trying to display result.title - try changing this to result.company_name for example.

@travis-r6s
Copy link
Owner

travis-r6s commented Jan 1, 2020

P.S. You could also easily loop through the object keys, converting them to snake case, and setting _text as the direct value:

const { snakeCase } = require('snake-case')
for (const item of predata.Listings.Listing) {
    const doc = Object.entries(item).reduce((obj, [key, value]) => ({ [ snakeCase(key) ]: value._text, ...obj }), {})
    contentType.addNode(doc)
}

@cartoonmadrasah
Copy link
Author

Oh wow, thank you so much.

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