【发布时间】:2015-03-17 10:56:42
【问题描述】:
我有一个问题,我想为 mongodb 实现全文搜索,所以我被卡住了,因为在数据库中只为文本搜索创建了一个索引,我想有多个搜索字段.. 模式示例:
name: {
type: String,
required: true,
trim: true,
index: 'text'
},
sub_name: {
type: String,
trim: true
},
location: [{
geo: {
type: [Number],
index: '2d'
},
description: {
type: String,
trim: true,
index: 'text'
},
address: {
city: {
type: String,
index: 'text'
},
street: {
type: String,
index: 'text'
},
state: {
type: String,
index: 'text'
}
},
那么这样做的诀窍是什么?如何应用多个字段进行全文搜索? thx for anwser ...
【问题讨论】:
标签: mongodb express indexing mongoose