MongoDB全文搜索——目前尚不支持针对特定field的搜索
> db.articles.createIndex( { subject: "text" } )
{
"createdCollectionAutomatically" : true,
"numIndexesBefore" : ,
"numIndexesAfter" : ,
"ok" :
}
> db.articles.insert(
... [
... { _id: , subject: "coffee", author: "xyz", views: },
... { _id: , subject: "Coffee Shopping", author: "efg", views: },
... { _id: , subject: "Baking a cake", author: "abc", views: },
... { _id: , subject: "baking", author: "xyz", views: },
... { _id: , subject: "Caf Con Leche", author: "abc", views: },
... { _id: , subject: ".......", author: "jkl", views: },
... { _id: , subject: "coffee and cream", author: "efg", views: },
... { _id: , subject: "Cafe con Leche", author: "xyz", views: }
... ]
... )
BulkWriteResult({
"writeErrors" : [ ],
"writeConcernErrors" : [ ],
"nInserted" : ,
"nUpserted" : ,
"nMatched" : ,
"nModified" : ,
"nRemoved" : ,
"upserted" : [ ]
})
> db.articles.find( { $text: { $search: "coffee" } } )
{ "_id" : , "subject" : "Coffee Shopping", "author" : "efg", "views" : }
{ "_id" : , "subject" : "coffee and cream", "author" : "efg", "views" : }
{ "_id" : , "subject" : "coffee", "author" : "xyz", "views" : }> db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
{ "_id" : , "subject" : "Coffee Shopping", "author" : "efg", "views" : }
> db.articles.find( { $text: { $search: "\"coffee\" \"shop\"" } } )
{ "_id" : , "subject" : "Coffee Shopping", "author" : "efg", "views" : }
> db.articles.find( { $text: { $search: "coffee shop" } } )
{ "_id" : , "subject" : "Coffee Shopping", "author" : "efg", "views" : }
{ "_id" : , "subject" : "coffee and cream", "author" : "efg", "views" : }
{ "_id" : , "subject" : "coffee", "author" : "xyz", "views" : }
参考:https://docs.mongodb.com/manual/reference/operator/query/text/
MongoDB全文搜索——目前尚不支持针对特定field的搜索的更多相关文章
- Lucene in action 笔记 term vector——针对特定field建立的词频向量空间,不存!不会!影响搜索,其作用是告诉我们搜索结果是“如何”匹配的,用以提供高亮、计算相似度,在VSM模型中评分计算
摘自:http://makble.com/what-is-term-vector-in-lucene given a document, find all its terms and the posi ...
- 一:cocos2dx 3.2 尚不支持cubeMap?二:光照需要shader实现
一: cocos2dx 3.2 尚不支持cubeMap? 因为需要调用cocos2dx 封装的bindTexture的方法,发现只能绑定2DTexture,对Cube_Map无能无力.顿感累觉不爱…… ...
- lucene全文搜索之四:创建索引搜索器、6种文档搜索器实现以及搜索结果分析(结合IKAnalyzer分词器的搜索器)基于lucene5.5.3
前言: 前面几章已经很详细的讲解了如何创建索引器对索引进行增删查(没有更新操作).如何管理索引目录以及如何使用分词器,上一章讲解了如何生成索引字段和创建索引文档,并把创建的索引文档保存到索引目录,到这 ...
- 安装更新时出现一些问题,但我们稍后会重试。如果你继续看到此错误,并且想要搜索 Web 或联系支持人员以获取相关信息,以下信息可能会对你有帮助: (0x80070426)
安装更新时出现一些问题,但我们稍后会重试.如果你继续看到此错误,并且想要搜索 Web 或联系支持人员以获取相关信息,以下信息可能会对你有帮助: (0x80070426) https://answers ...
- (GoRails)在导航栏增加自动的搜索功能(jquery插件:easyautocomplete)(gem 'ransack' 搜索对象4000✨)
Global Autocomplete Search 需要用到一个JQuery插件和一个搜索对象的gem EasyAutocomplete jQuery插件: https://github.com/p ...
- html小知识点汇总(浏览器导航上显示图标、div无高度时试着清除浮动、文字环绕图片、字体加粗、div按百分比分、已有的不合适的class,针对特定的标签进行修改)
1.新点击的网页,在浏览器导航上显示图标: 像这种效果: <head> <meta charset="UTF-8"> <meta name=" ...
- 【代码笔记】iOS-点击搜索按钮,或放大镜后都会弹出搜索框
一, 效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "CLHSearchBar.h ...
- Microsoft Dynamics CRM 2013 --针对特定实体,取消保存功能(包含自动保存)
AutoSave 是 Microsoft Dynamics CRM 2013 一个新特性. 但AutoSave的有效范围是[所有实体],不允许针对特定某一实体进行设置. 所以,若想针对特定实体进行设置 ...
- 更新xcode后插件失效问题——不针对特定版本的通用解决方法
一.Xcode更新后插件失效的原理 1.每次更新Xcode后插件都会失效,其实插件都还在这个目录好好的躺着呢: ~/Library/Application Support/Developer/Shar ...
随机推荐
- AutoEncoders原理
目录 Auto-Encoders How to Train? Auto-Encoders How to Train?
- 杭电 5363 求集合的非空子集中key的数量
Description soda has a set S with n integers {1,2,…,n}. A set is called key set if the sum of intege ...
- 标准sqlserver连接语句
sqlserver左右全内连接 原始链接http://www.cnblogs.com/youzhangjin/archive/2009/05/22/1486982.html 连接条件可在FR ...
- Android RoundedBitmapDrawable:Android官方的圆角图形图象实现方案
Android RoundedBitmapDrawable:Android官方的圆角图形图象实现方案 RoundedBitmapDrawable是Android在support v4的扩展包中新 ...
- POJ-1988Cube Stacking/HDU-2818Building Block;
Cube Stacking Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 23283 Accepted: 8166 Ca ...
- fd最大值和限制
fd的数量决定了fd的最大值 在Linux下,系统全部能够打开的fd总数为: /proc/sys/fs/file-max,取决于内存 The file-max file /proc/sys/fs/fi ...
- Automation 的 ReportFlow
ReportFlow: // click the Grid icon and switch to grid page public void changeToGrid() // click the A ...
- 不能更通俗了!KMP算法实现解析
我之前对于KMP算法理解的也不是很到位,如果很长时间不写KMP的话,代码就记不清了,今天刷leetcode的时候突然决定干脆把它彻底总结一下,这样即便以后忘记了也好查看.所以就有了这篇文章. 本文在于 ...
- 593. Valid Square
Problem statement: Given the coordinates of four points in 2D space, return whether the four points ...
- [NOIP2008] 提高组 洛谷P1125 笨小猴
题目描述 笨小猴的词汇量很小,所以每次做英语选择题的时候都很头疼.但是他找到了一种方法,经试验证明,用这种方法去选择选项的时候选对的几率非常大! 这种方法的具体描述如下:假设maxn是单词中出现次数最 ...