Closed ramsaymax closed 7 years ago
Hi Matt,
Thanks for getting back to me. The code I'm using is as follows:
Index
import {
Creators
}
from './Creators.js';
import {
EasySearch
}
from 'meteor/easy:search';
import {
_
}
from 'meteor/underscore';
import {
Index, MongoDBEngine
}
from 'meteor/easy:search';
export const CreatorsIndex = new Index({
engine: new MongoDBEngine({
fields: function (searchObject, options) {
// return searchObject.find({}, {fields: {"_id": 1}});
// searchObject['_source.display_name'] = {"fields": {"_id": 1}};
// return {"_source.display_name": 1};
return {
"_source.display_name": 1,
"_source.accounts.thumbnail": 1,
"_source.country": 1
};
},
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,
};
}
},
selector: function (searchObject, options, aggregation) {
const selector = this.defaultConfiguration().selector(searchObject, options, aggregation);
console.log(selector);
// filter for the brand if set
if (options.search.props.country) {
var countries = options.search.props.country;
selector['_source.country'] = {
$in: countries
};
}
if (options.search.props.facebookCategory) {
var facebookCategory = options.search.props.facebookCategory;
selector['_source.facebook_category'] = {
$in: facebookCategory
};
}
if (options.search.props.category) {
var categories = options.search.props.category;
selector['_source.content_category.id'] = {
$in: categories
};
}
if (options.search.props.network) {
selector['_source.network'] = options.search.props.network;
}
if (options.search.props.gender) {
var preGender = options.search.props.gender;
console.log(preGender);
selector['_source.accounts.demographics.gender.' + preGender] = {
$gt: 50
};
}
if (options.search.props.subscribers) {
rangeValue = options.search.props.subscribers;
lowerValue = rangeValue[0];
highValue = rangeValue[1];
selector['_source.total_followers'] = {
$gte: lowerValue,
$lt: highValue
};
}
if (options.search.props.monthly_views) {
rangeValue = options.search.props.monthly_views;
lowerValue = rangeValue[0];
highValue = rangeValue[1];
// console.log(selector['_source.monthly_stats']);
selector['_source.monthly_stats.total_views'] = {
$gte: lowerValue,
$lt: highValue
};
}
return selector;
},
}),
collection: Creators,
// fields: ['_source.display_name'],
fields: ['_source.display_name'],
defaultSearchOptions: {
limit: 32
},
permission: () = > {
//console.log(Meteor.userId());
return true;
}
});
Template
<template name="creatorDeck">
<div class="search_area">
<div class="search_container">
<div class="ui big form">
<div class="field">
{{> creatorDeckLabels}}
<div class="ui right labeled input">
{{> EasySearch.Input index=index allDocsOnEmpty=true attributes=inputAttributes}}
<div class="ui dropdown label black basic button 0 vw">
<div class="text vw">Filters </div>
<i class="dropdown icon"></i>
</div>
</div>
</div>
<div class="field"></div>
</div>
<div class="narrowFilters">
{{> filters}}
</div>
</div>
{{>myLists}}
{{> sortDropDown}}
<span><br></span>
</div>
{{resultsCountHidden}}
{{#if loadchecker}}
<h4 class="ui horizontal divider header vw wow fadeIn">
{{resultsCount}} creators found.
</h4>
{{/if}}
{{#EasySearch.IfNoResults index=index}}
<!-- <h4 class="ui horizontal divider header">No results</h4> -->{{/EasySearch.IfNoResults}}
<div class="creatorcontainer">
{{#if loadchecker}} {{else}}{{> spinner}} {{/if}}
<div class="ui eight stackable special cards">
{{#EasySearch.Each index=index }}
{{#if loadchecker}}
<a class="ui card wow fadeIn" href="/profiles/{{__originalId}}">
{{> creatorCard}}
</a>
{{else}}
{{/if}}
{{/EasySearch.Each}}
</div>
</div>
<div class="LoadMore">
<div class="ui one column stackable center aligned page grid">
{{> EasySearch.LoadMore count=24 index=index attributes=attributes}}
</div>
</div>
</template>
Helper
import './creatorDeck.html';
import './spinner.html';
import './sortDropDown.html';
import './sortDropDown.js';
import './filters.html';
import './filters.js';
import './filtersCountry.html';
import './filtersCountry.js';
import './filtersNetwork.html';
import './filtersNetwork.js';
import './filtersDemographic.html';
import './filtersDemographic.js';
import './filtersGender.html';
import './filtersGender.js';
import './filtersAudienceLocation.js';
import './filtersAudienceLocation.html';
import './subscriberSlider.js';
import '../creatorCard/creatorCard.js';
import {
Meteor
}
from 'meteor/meteor';
import {
Template
}
from 'meteor/templating';
import {
EasySearch
}
from 'meteor/easy:search';
import {
Creators
}
from '../../collections/creators/Creators.js';
import {
CreatorsIndex
}
from '../../collections/creators/CreatorsIndex.js';
import {
$
}
from 'meteor/jquery';
Template.body.onRendered(function () {
$('head').append('<script type="text/javascript" src="/js/gradient.js"></script>');
});
Meteor.startup(function () {
Meteor.typeahead.inject();
});
Template.creatorDeck.onRendered(function () {
Session.set('loadCheck', false)
new WOW().init();
CreatorsIndex.getComponentMethods()
Meteor.typeahead.inject();
$('.clicker').hide();
$("div.LoadMore").hide();
$(window).scroll(function () {
if ($(this).scrollTop() != 0) {
$("div.LoadMore").fadeIn();
} else {
$("div.LoadMore").fadeOut();
}
});
$(".button").eq(0).click(function () {
var $target = $('.narrowFilters'),
$toggle = $(this);
$target.slideToggle(function () {
$toggle.text(($target.is(':visible') ? 'Hide ' : 'Show ') + 'Filters');
});
});
});
Template.creatorDeck.events({
'change .sorting': (e) = > {
CreatorsIndex.getComponentMethods()
.addProps('sortBy', $(e.target).val())
},
});
Template.creatorDeck.helpers({
inputAttributes: function () {
return {
'class': '',
'placeholder': 'Start searching...'
};
},
index: function () {
return CreatorsIndex;
},
resultsCount: function () {
return CreatorsIndex.getComponentDict().get('count');
},
resultsCountHidden: function () {
initialLoadLog = CreatorsIndex.getComponentDict().get('currentCount');
if (initialLoadLog === 32) {
Session.set('loadCheck', true)
}
},
loadchecker: function () {
return Session.get('loadCheck')
},
attributes: function () {
return {
class: 'ui teal basic compact button hideonload'
};
},
renderTmpl: () = > Template.renderTemplate
});
Does setting countUpdateIntervalMs to 0 or 5000+ (5 seconds) like described here #556 help?
I'm sorry but i need more compact and reproduceable issues to fix them.
can you show me your configuration? EasySearch should be able to handle the data. Also the stack trace you pasted in shows an error in the kadira pkg.