简体   繁体   English

在多个Mongo列中搜索多个条目

[英]Search multiple Mongo columns for multiple entries

I have made a nice pageing system that is ajax dynamic with .net, mongodb, and twitter bootstrap. 我已经制作了一个不错的分页系统,它具有.net,mongodb和twitter引导程序的ajax动态功能。 Everything works great but now I would like to have a text box where the user can search and ajax/mongo driver search all fields of a collection and return the results, a perfect example of my goal can be seen here at the datatables plugin. 一切都很正常,但现在我想有一个文本框,用户可以搜索和Ajax /蒙戈驱动程序搜索集合的所有领域,并返回结果,我的目标一个完美的例子可以看出这里的数据表插件。 I have tried a few things such as combing all of the columns with an or: 我尝试了一些操作,例如用or组合所有列:

Query.Or(
    Query.Matches("Name", new BsonRegularExpression(query, "i")),
    Query..Matches("Facility.Name", new BsonRegularExpression(query, "i")),
    etc...
)

Which I suppose in theory is the way you could do it, however I was hopeing for a solution a little more universal. 从理论上讲,我认为这是您可以做到的方式,但是我希望有一个更通用的解决方案。 When you use the data tables plugin i linked it will search all data no matter what and organize it properly (i realize this is html not a DB) but is there a systematic way to do this with MongoDB? 当您使用我链接的数据表插件时,它将搜索所有数据,无论如何并对其进行适当地组织(我意识到这是html而不是DB),但是是否有系统的方法可用于MongoDB? Any one have any pointers? 有人有指针吗?

MongoDB text indexes will allow you to create a text index on specific fields within a document or on all fields within each document. MongoDB 文本索引将允许您在文档内的特定字段或每个文档内的所有字段上创建文本索引 After you've created the index you can use the $text operator to performa a search. 创建索引后,可以使用$ text运算符执行搜索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM