Closed ramsaymax closed 7 years ago
Are you using easy search components? Also notice that the easy search leaderboard loads documents by default
what was the problem? 😄
Hey!
I changed:
sort: function (searchObject, options) {
const sortBy = options.search.props.sortBy
if ('relevance' === sortBy) {
return {
'establishment.visitCount': -1,
}
} else if ('followers' === sortBy) {
return {
'establishment.RatingsCount': -1,
}
} else if ('growth' === sortBy) {
return {
'establishment.DemoterCount': -1,
}
} else {
throw new Meteor.Error('Invalid sort by prop passed')
}
}
sort: function (searchObject, options) {
const sortBy = options.search.props.sortBy
if ('relevance' === sortBy) {
return {
'establishment.visitCount': -1,
}
} else if ('followers' === sortBy) {
return {
'establishment.RatingsCount': -1,
}
} else if ('growth' === sortBy) {
return {
'establishment.DemoterCount': -1,
}
} else {
throw new Meteor.Error('Invalid sort by prop passed')
}
}
to
sort: function (searchObject, options) {
const sortBy = options.search.props.sortBy
// return a mongo sort specifier
if ('relevance' === sortBy) {
return {
'_source.accounts.influencer_score': -1,
}
} else if ('followers' === sortBy) {
return {
'_source.total_followers': -1,
}
} else if ('growth' === sortBy) {
return {
'_source.total_followers_growth': -1,
}
} else {
return {
'_source.accounts.influencer_score': -1,
}
}
},
Hey Matt,
I'm having a weird issue with sorting in easysearch that I've spent hours trying to fix.
I've basically copied the example "Add sorting to you app" line for line exactly:
http://matteodem.github.io/meteor-easy-search/docs/recipes/
it works great, the only issue is that when the app loads it does not load documents by default. Only when I select a sort from the drop down will it load documents.
The moment I remove the sort logic and add a basic return, default documents are there.
I believe it has something to do with this code:
I've tried passing in the defaultSearchOptions too:
and also wont work
I think the documentation might be lacking in an explanation for this