> 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的搜索的更多相关文章

  1. 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 ...

  2. 一:cocos2dx 3.2 尚不支持cubeMap?二:光照需要shader实现

    一: cocos2dx 3.2 尚不支持cubeMap? 因为需要调用cocos2dx 封装的bindTexture的方法,发现只能绑定2DTexture,对Cube_Map无能无力.顿感累觉不爱…… ...

  3. lucene全文搜索之四:创建索引搜索器、6种文档搜索器实现以及搜索结果分析(结合IKAnalyzer分词器的搜索器)基于lucene5.5.3

    前言: 前面几章已经很详细的讲解了如何创建索引器对索引进行增删查(没有更新操作).如何管理索引目录以及如何使用分词器,上一章讲解了如何生成索引字段和创建索引文档,并把创建的索引文档保存到索引目录,到这 ...

  4. 安装更新时出现一些问题,但我们稍后会重试。如果你继续看到此错误,并且想要搜索 Web 或联系支持人员以获取相关信息,以下信息可能会对你有帮助: (0x80070426)

    安装更新时出现一些问题,但我们稍后会重试.如果你继续看到此错误,并且想要搜索 Web 或联系支持人员以获取相关信息,以下信息可能会对你有帮助: (0x80070426) https://answers ...

  5. (GoRails)在导航栏增加自动的搜索功能(jquery插件:easyautocomplete)(gem 'ransack' 搜索对象4000✨)

    Global Autocomplete Search 需要用到一个JQuery插件和一个搜索对象的gem EasyAutocomplete jQuery插件: https://github.com/p ...

  6. html小知识点汇总(浏览器导航上显示图标、div无高度时试着清除浮动、文字环绕图片、字体加粗、div按百分比分、已有的不合适的class,针对特定的标签进行修改)

    1.新点击的网页,在浏览器导航上显示图标: 像这种效果: <head> <meta charset="UTF-8"> <meta name=" ...

  7. 【代码笔记】iOS-点击搜索按钮,或放大镜后都会弹出搜索框

    一, 效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "CLHSearchBar.h ...

  8. Microsoft Dynamics CRM 2013 --针对特定实体,取消保存功能(包含自动保存)

    AutoSave 是 Microsoft Dynamics CRM 2013 一个新特性. 但AutoSave的有效范围是[所有实体],不允许针对特定某一实体进行设置. 所以,若想针对特定实体进行设置 ...

  9. 更新xcode后插件失效问题——不针对特定版本的通用解决方法

    一.Xcode更新后插件失效的原理 1.每次更新Xcode后插件都会失效,其实插件都还在这个目录好好的躺着呢: ~/Library/Application Support/Developer/Shar ...

随机推荐

  1. 树莓派--bcm2835 library (2) 交叉编译BCM2835

    在上文中,按照guide, 在树莓派目标板上install bcm2835. 因为bcm2835是用户空间应用,所以可以在宿主机上交叉编译,生成binary后在树莓派执行 按照guide: Insta ...

  2. LeetCode(41)First Missing Positive

    题目 Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2 ...

  3. 32道常见的Java基础面试题

    1. 什么是 Java 虚拟机(JVM)?为什么 Java 被称作是“平台无关的编程语言”? Java 虚拟机是一个可以执行 Java 字节码的虚拟机进程.Java 源文件被编译成能被 Java 虚拟 ...

  4. 九度oj 题目1525:子串逆序打印

    题目1525:子串逆序打印 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:3124 解决:530 题目描述: 小明手中有很多字符串卡片,每个字符串中都包含有多个连续的空格,而且这些卡片在 ...

  5. Codeforces Round #304 (Div. 2)-D. Soldier and Number Game,素因子打表,超时哭晕~~

    D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input s ...

  6. MTK平台 GPU 相关知识

    一.什么是Render script,以及mtk平台GPU support情况 [DESCRIPTION] 1.什么是RenderScript ? 2.RenderScript 干什么? 3.MTK平 ...

  7. Python基础之 一 字典(dict)

    字典:是一种key - value的数据类型.语法:info = { key:value }特性:无序,key必须唯一(所以天生去重) 方法如下:del dict[key]:删除字典指定键len(di ...

  8. Elasticsearch自定义客户端(TransportClient)资源池

    前言: java中调用TransportClient时,我们一般都会设置成单例,为了避免多次的创建与关闭造成的内存占用及关闭缓慢问题.而TransportClient本身也是实现了线程池threadP ...

  9. Ubuntu 16.04下减小/释放/清理VirtualBox虚拟硬盘文件的大小

    一般在VirtualBox中安装Windows,然后用无缝模式进行某些特定软件的使用. 而VirtualBox的虚拟硬盘会越用越大,并且VirtualBox没有自带清理工具,相比VMware来说,VM ...

  10. Servlet实现页面重定向

    以下内容引用自http://wiki.jikexueyuan.com/project/servlet/page-redirect.html: 当文档移动到一个新的位置时,通常会使用页面重定向,需要将客 ...