Keyword search

node v8.9.4
version: master
endpointsharetweet
var qm = require('qminer'); // create the base object with the desired schema var base = new qm.Base({ mode: 'createClean', schema: [{ name: 'tweets', fields: [{ name: 'text', type: 'string' }], keys: [{ "field": "text", "type": "text_position" }] }] });
// push the data let tweetStore = base.store('tweets'); tweetStore.push({text: "This pen is green."}); tweetStore.push({text: "This pen is yellow."}); tweetStore.push({text: "This pen is blue."}); tweetStore.push({text: "This marker is yellow."});
let query = { $from: "tweets", $or: [{text: "pen"}, {text: "yellow"}] }; var res = base.search(query);
res.toJSON().records.forEach((obj) => { console.log(obj.text); })
Loading…

no comments

    sign in to comment