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

Full text search example #5

Closed
lbineau opened this issue Sep 30, 2017 · 3 comments
Closed

Full text search example #5

lbineau opened this issue Sep 30, 2017 · 3 comments

Comments

@lbineau
Copy link
Collaborator

lbineau commented Sep 30, 2017

Hi @cigolpl,

The search with facets are working very well but I can't find an example of full text search.
I see in the source code that you use lunrjs. Can you provide me a code sample with full text search and the fields to limit the search to?

Equivalent with lunrjs code

var idx = lunr(function () {
  this.field('title')
  this.field('body')

  this.add({
    "title": "Twelfth-Night",
    "body": "If music be the food of love, play on: Give me excess of it…",
    "author": "William Shakespeare",
    "id": "1"
  })
})
idx.search("love")

Another unrelated question, I saw you use the full library minified of lodash without npm. What is the reason behind it ? I'm also using lodash but with npm so I think lodash code will be duplicated in the end because there is no dependencies manager.
I could fork the project and do the modifications if it is not a deliberate choice.

@cigolpl
Copy link
Member

cigolpl commented Sep 30, 2017

Hello @lbineau,

  1. I have updated demo in readme for this case. Please ctrl+f for query and searchableFields

  2. As far as I remember I've minified only specific part of lodash to make it smaller for the client side (with bower). I've used this command lodash include=some,forEach,map,mapKeys,mapValues,every,includes,intersection,filter,keys,clone,flatten,transform,sortBy -o lib/lodash.js -p. I agree - decoupling it to npm if possible would be better

@lbineau
Copy link
Collaborator Author

lbineau commented Oct 1, 2017

So fast! Thank you it just works :)

Let me know if you want me to do something about npm. Now all the functions are in different files so you can require them separately.
Personnaly I use something like this on my new projects:

import _get from 'lodash/get' // import syntax
var _get = require('lodash/get') // or require syntax

What do you think?

@cigolpl
Copy link
Member

cigolpl commented Oct 1, 2017

@lbineau feel free to propose any changes anytime if you see a room for an improvement, even very small things.

  1. Personally I prefer var _get = require('lodash/get').
  2. The project should pass tests with command mocha tests/*

@lbineau lbineau closed this as completed Oct 3, 2017
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