Giter Site home page Giter Site logo

mongoose-text-search's People

Contributors

aheckmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mongoose-text-search's Issues

Support for populate

Given that this will sooner or later land in Mongoose, will things like populate be available then?

Do you have any thoughts on how to handle the meta data that the text command returns (per object like score or per query like stats)?

Edit: I don't know much about the internals of Mongoose (query interface etc.) but from the top of my Head I'd love to do this:

Post.find({foo: 'bar'}).text('kitten').populate('comments').exec(function(err, posts) {

});

If text is used with a String of length > 0 Mongoose uses the text command internally and passes the options of find as the filter property. sort is then of course ignored. But limit on the other hand can then be passed to the text command as well.

Index document and a linked doc together

Is there a way of indexing a document and linked document together?

For example, i have a schema "movie" with keywords in it but they are modeled as separate documents and referenced from movies. When i search i want the keyword metadata (name) to be included in the index.

Is this possible with this module?

Too little result

Is there any way I can get more result. In database I have:

gehen
gehen
gehend
gehende
gehendem
gehenden
gehender
gehendes
gehengelassen
gehenkt
gehenkte
gehenktem
gehenkten
gehenkter
gehenktes
gehenlassen
gehenlasst
gehenließ
gehenließen
gehenließet
gehenlässt
Gehens

However, when I search for "gehen", it returns only "gehen" and "Gehens". Is there any way I could get more relevant results?

Any help would be very appreciated

Allow passing an object

Currently the only thing that can be passed is a string which will be used as the search property for the text command. Things like filter, project or limit aren't possible. Similar question than #1: Are there plans to make this more Mongoose-like?

mongoose-text-search on existing DB

I have some difficult if I want apply the example code in an existing db.
Following your example i've write this code:

var url = require("url");
var express = require("express");
var app = express();      

app.get("/", function(request, response, next) {
    response.header("Access-Control-Allow-Origin", "*");

                var mongoose = require('mongoose');
                mongoose.connect('localhost', 'blomming');

                var textSearch = require('mongoose-text-search');                   

                var blommingSchema = mongoose.Schema({
                    name: String,
                    description: [String],
                    url: String,
                    price: String,
                    original_price: String,
                    currency: String,
                    photos: [{
                        first:String,
                        second:String
                    }],
                    quantity: String,
                    fbcomments: String,
                    shop: [{
                        id:String,
                        url:String,
                        items_url:String,
                        name:String,
                        image:String
                    }],

                });

                blommingSchema.plugin(textSearch);               
                blommingSchema.index({ description : 'text' });               
                var blommingDoc = mongoose.model('products', blommingSchema);

    var options = {
       limit: 10
    }

    blommingDoc.textSearch('specchio',options, function (err, output) {
        if (err) throw err;
        console.log(output);
        return response.send(JSON.stringify({"success" : true, "data" : output}));
        return response.end();
    });

});

app.listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

I've runned a debug step by step and the problem is this.
If I use a callback similar to "Game.create({ name: 'Super Mario 64', tags: ['nintendo', 'mario', '3d'] }, function (err) {" the debug enter inside a function blommingDoc.textSearch. If I don't use this it doesn't enter inside. But i don't need to create stuff each time that i want to search something.
Also on your example code if I comment the create function the debug jump over and doesn't reach the textSearch function.
I'm a newbie of nodejs and mongodb so i'm sorry if the solution is trivial.
Could you help me ?
Thanks.

text search not enabled

That is what I got when trying to run the provied example:

{ name: 'MongoError',
message: 'text search not enabled',
ok: 0,
errmsg: 'text search not enabled' }

Supporting offset and sort options

Very useful plugin. Thanks!

Are there plans to support a offset and sort option? I would like to paginate full text search results based on a specified sort order.

mongoose-text-search is not working

I have a already built old project on nodejs where I am using MongoDb to store data. Mongodb version is 2.4

The problem is I am running a text-search on a collection but it's never return anything which means console.log(arguments); never get print anything

It's to inform you guys that I am able to run db.socialposts.runCommand( "text", { search: "accessories",limit: 1 } ) on mongo terminal and getting results very fast

var options, search;

options = {
limit: 1
};

search = 'accessories';

console.log(search);

SocialPost.textSearch(search, options, function(err, out) {
console.log(arguments);
return true;
});

It's Schema is

var schema;
schema = new mongoose.Schema({
entity_id: {
type: mongoose.Schema.Types.ObjectId,
required: true
},
social_id: {
type: String,
required: true
},
type: {
type: String,
required: true
},
app: {
type: String,
required: true
},
date: {
type: Date,
required: true
},
url: {
type: String,
required: true
},
post: {
type: String
},
title: {
type: String
},
image: {
type: String
},
video: {
type: String
},
hashtags: [String]
}, {
strict: 'throw'
});

And Index is

schema.index({
type: 1,
social_id: 1
});

schema.index({
type: 1,
entity_id: 1,
date: 1
});

schema.index({
title: 'text',
post: 'text'
});

Pagination

I'm not sure if pagination is possible with mongoose-text-search.

In my local mongo 2.6, I put all the find options together using this from node/mongoose:

var query = Contact.find(findOpt);
query.count(function(err, count) {
query.skip((req.query.page-1)*numContactsPerPage).limit(numContactsPerPage).
exec('find', function(err, contacts) {
...
});
});

But now using conservative mongolab/mongohq mongo 2.4, I don't know how to do it.

Any suggestion? Thanks.

Does not work with Mongoose 3.8.12 + Plugin setup

I attempted to follow the example of:

gameSchema.plugin(textSearch);

But the only thing that worked for me was to run the schema through the plugin instead, after declaring extra statics such as:

gameSchema.statics = {
   load: function (id, cb) {//code here}
};

textSearch(gameSchema);

Project not fully working

My documents have the following object inside

"random": {
    "coordinates": [
        0.8316348162479699,
        0.0699989115819335
    ],
    "type": "Point"
}

but when I use

project: "-random"

the random field still shows.

Edit: it's not only that field, i tried projecting in reverse (only including the field I want like: "title") but random field and two others are still showing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.