Meteor js:在用户集合中创建索引 [英] Meteor js: Create index in user collection

查看:61
本文介绍了Meteor js:在用户集合中创建索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有全名字段的用户集合(即Jose Osorio,Jose Castro,John smith,Maria Smith),我需要创建一个搜索栏来查找注册用户的姓名或名字。

I create a user collection with a fullname field (i.e. Jose Osorio, Jose castro, John smith, Maria Smith), I need to create a search-bar to find registered users by their name or last name.

即在搜索栏中写道,我希望看到何塞·奥索里奥和何塞·卡斯特罗。

I.e. write in the search-bar jose and I want to see Jose Osorio and Jose castro.

我在数据库中读到了关于创建索引但是它没有用,或者我做了那个错了,我该怎么做才能解决这个问题?

I read about create Index in the database but it did not work or I did that wrong, what can i do to solve this?

推荐答案

你也可以使用 rawCollection 像这样:

Products.rawCollection().createIndex({
    "type": "text",
    "searchString": "text",
    "title": "text",
    "brand": "text",
    "description": "text"
}, { 
    "weights": {
        type: 5,
        brand: 4,
        title: 3,
        searchString: 3,
        description: 1
    }
});

这篇关于Meteor js:在用户集合中创建索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆