English 中文(简体)
mongodb 最接近的字符串匹配查找
原标题:mongodb closest string match lookup

Is there any functionality in mongo to retrieve closest string match lookups. For example, Entries in the database are like:

  • title: "bananashake"
  • title: "bananasweet"
  • title: "bananaturl"
  • and so forth...

假设用户输入了一些像“香蕉weeest”的文字。

最佳回答

Since Mongodb v2.4, you can create a Fulltext index to search through your data by creating an index db.reviews.ensureIndex( { comments: "text" } )

Document

问题回答

您显然正在寻找在 MOngoDB 中无法使用的全文功能。 查看 Solr 或 ElasticSearch - 不属于 MOngoDB 范围 。

视您在寻找什么具体内容而定,您可以用一个regex 查询来做到这一点: < a href="http://www.mongodb.org/display/DOCS/Advancedueries#AdvancedQueries-RegularExpressions\ rel=“nofollow”>http://www.mongodb.org/display/DOCS/Advancedueries#AdvancedQueries-RegularExpressions

是的,我同意,Solr和ElasticSearch是一个很好的替代办法。您也可以花时间在Jira就这个服务器问题进行投票:https://jira.mongodb.org/browse/SERVER-380





相关问题
How can I make a query string tamper-proof?

I need to use query strings in a URL, but need to ensure that they haven t been tampered with. I found a solution which almost works, but the encoded strings get mangled by a service my app needs to ...

Passing Lists as a QueryString - should I use JSON

Lets say I ve got an online dating site, users can filter the user list based on various criteria, Height, Age, BodyType, Ethnic Origin.... I want to pass the criteria to the pager, via QueryString. ...

Is using URL query string variables still RESTful

I m presented with a problem of using query string variables in a RESTful Asp.net MVC application. Does that violate the RESTful pattern? The thing is that Asp.net MVC uses default route like: /...

URL requests adding POST data to querystring

I am using ExtJS to send an Ajax request to a PHP page on a server, wanting to send the parameters as POST variables rather than in the querystring. I have included a random token in the querystring ...

Maintain the querystring in all pages in mvc

I need to maintain the querystring in all pages in my asp.net mvc(C#) application. For ex.: I will call a page www.example.com?Preview=True. The querystring should be maintained whatever the page i ...

Nginx 301 redirect inc. set cookie

what I m looking for is the ability for nginx to detect that a url has the query string variable cid. for example www.adomain.com/froggy?cid=12&as=false (query string can be solo or mixed with ...

ASP.NET: URI handling

I m writing a method which, let s say, given 1 and hello should return http://something.com/?something=1&hello=en. I could hack this together pretty easily, but what abstraction functionality ...

Checking querystring values in PHP

http://localhost/?area=characters&name=Michal+Stroganof $result = mysql_query("SELECT * from players WHERE name = $_GET[name] "); while ($row = mysql_fetch_assoc($result)) { echo "Name: " ....

热门标签