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

Documentation missing for elastic search #643

Open
Shelagh-Lewins opened this issue Mar 15, 2019 · 5 comments
Open

Documentation missing for elastic search #643

Shelagh-Lewins opened this issue Mar 15, 2019 · 5 comments

Comments

@Shelagh-Lewins
Copy link

The docs for choosing engines have a broken link to elastic search instructions:

http://matteodem.github.io/meteor-easy-search/docs/engines/

https://github.com/matteodem/meteor-easy-search/tree/master/packages/easysearch:elasticsearch

Is elastic search no longer supported? Or have the instructions moved?

Thank you for this great package which still seems to be the go-to search package for Meteor.

@Shelagh-Lewins
Copy link
Author

I tried to get elasticsearch working but no luck. I installed elasticsearch and checked the service is running.

I then added the elasticsearch package:

meteor add easysearch:elasticsearch@=2.1.0

and tried to use the elasticsearchengine in my template:

import { Index, ElasticSearchEngine } from 'meteor/easy:search';
import { Projects } from '../schemas/schemas';

// On Client and Server
const UsersIndex = new Index({
	'collection': Meteor.users,
	'defaultSearchOptions': { 'limit': 10 },
	'fields': ['username', 'email'],
	'engine': new ElasticSearchEngine(),
});

I got a server error:
TypeError: ElasticSearchEngine is not a constructor

@meecect
Copy link

meecect commented Oct 21, 2019

I was able to get it running, but you have to make a few modifications as ElasticSearch has deprecated a few things.

For one,
easy-search composes an elastic search 'body' that specifies a 'fields' property. That is no longer the right way to specify the return values. You should use '_source'.

Next, if the fields you are indexing (for the easy search collection) have a 'text' type, easy search adds them by default to the 'sort' option to elastic, but that causes elastic to throw an error but it warns you about putting text types in memory for sorting and aggregating.

So I was able to at least get it to work (maybe not an ideal way) by doing this:

export const PostsElasticIndex = new Index({
  collection: Posts,
  name: 'postsElasticIndex',
  fields: ['title','content'],
  engine: new ElasticSearchEngine({
    body: function(body, options) {
      delete body.fields;
      delete body.sort;
      body._source= '_id';
      return body;
     } // modify the body that's sent when searching
  }),
  defaultSearchOptions: { limit: 25 }, // default options when searching

})

I can provide more details if this is still something you need.

@meecect
Copy link

meecect commented Oct 21, 2019

oh, also, you need to explicitly include the elastic engine, so this:

meteor add easysearch:elasticsearch

and:

import { Index, MongoDBEngine } from 'meteor/easy:search'
import { ElasticSearchEngine } from 'meteor/easysearch:elasticsearch'

@Shelagh-Lewins
Copy link
Author

Thanks! I'll probably come back to this on my next project.

@matteodem
Copy link
Owner

The docs are here https://github.com/matteodem/meteor-easy-search/tree/master/packages/easysearch_elasticsearch Any pr fixing the links in the gh-pages branch are greatly appreciated.

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

No branches or pull requests

3 participants