Closed Xenophyte closed 7 years ago
Can you please show me your EasySearch configuration together with what exactly your problem is?
My configuration:
NodesSearchIndex = new EasySearch.Index({
collection: Nodes,
fields: ['name', 'description'],
engine: new EasySearch.Minimongo({
selector: function(searchObject, options, aggregation) {
var selector = this.defaultConfiguration().selector(searchObject, options, aggregation);
if (options.search.props.type) {
selector.type = options.search.props.type;
};
return selector;
}
})
});
I've got two collections: Nodes and Personal. The objects in personal connect a user to a node:
{ _id: xxxxxx,
nodeId: yyyyyy,
userId: zzzzzz,
state: 0.8 }
I want to search only items in Nodes that have a state greater than 0.8 for the current logged user. My solution was to filter Nodes with a composite publish and then search the published data in Nodes with easy search for name, etc. An example of a Node is:
{ _id: yyyyy,
name: "this node",
description: "just a node" }
So, like I wrote above, if I type in the search box "concept", I'll get only the the Nodes that contain the word "concept" in either their name or description, but the array of returned objects will contain an empty _id and not contain at all other fields. For example, if I type in my browser's console Nodes.findOne({name: "concept"}) I get
{ _id: akjfhSHJKQ, name: "concept", description: "no description", views: 12, likes: 6 }
but easysearch only returns
{ _id: undefined, name: "concept", description: "no description" }
Are those properties dynamically computed? As in, not part of the raw mongo doc that's stored in the backend?
I wasn't able to reproduce it locally with the easy-search leaderboard example. Please give me a reproduction repository or steps to reproduce with an empty project.
Be sure to publish all your fields and then it should work as expected
Hi,
I'm using minimongo as my easy search engine because I need to filter results first with a composite publish. The trick works and I only get the filtered data, however the returned data only contains two fields:
{_id: undefined, name: "concept", description: ""}
despite the fact that in the client console I can access quite a bit more
{ _id: "DRNk7LhKjpkwqhoXD" attempts: 0 content: Object created_on: 1452264617921 description: "" dislikes: 0 grants: Object likes: 0 name: "unit" needs: Object successes: 0 type: "content" proto: Object }
How do I access the rest of the fields? (most importantly the _id!)
Thanks!