> 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. 在Linux中CSV转换成XLSX

    在linux中,把csv文件转换成excel表格(xlsx或者xls) $ echo -e 'surname,name,age\nCarlo,Smith,23\nJohn,Doe,46\nJane,D ...

  2. socket scoketserver

    import socket sk = socket.socket() # 创建了一个socket对象 # sk.setsockopt(socket.SOL_SOCKET,socket.SO_REUSE ...

  3. Jbox 弹出窗口 子页面操作完成后关闭 父页面刷新

    父页面js //父页面js <script> var isFreshFlag = '1'; //添加会议活动 function addMeetingAct(){ var attendVip ...

  4. LeetCode(55)Jump Game

    题目 Given an array of non-negative integers, you are initially positioned at the first index of the a ...

  5. 集训第四周(高效算法设计)P题 (构造题)

    Description   There are N<tex2html_verbatim_mark> marbles, which are labeled 1, 2,..., N<te ...

  6. 全文搜索(A-3)-用户建模

    用户模型可以分为静态模型.动态模型.混合推荐用户模型. 静态模型往往通过显式方式收集用户偏好信息: 动态模型通过隐式方式收集用户偏好信息: 基于内容的用户系统的推荐模型: 关键字匹配,空间向量模型 协 ...

  7. CSU 1259 bfs找最短路

    题目大意: 不想介绍,题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1259 bfs求最短路. 这里因为2-9,到达同样的点不计步数,那我 ...

  8. ZOJ1004 && HDU1515 dfs回溯

    题目大意: 就是通过一个栈进行字母入栈出栈得到想要的字符,把所有可能的方式全部输出 自己写的方法一开始一直不能过,后来参考了别人的方法,写出来的比较简单的代码 这段代码更有回溯的感觉,自己后来又把自己 ...

  9. [luoguP1981] 表达式求值(U•ェ•*U)

    传送门 弄两个栈,一个存数,一个存运算符,然后乱搞. 代码 #include <cstdio> #include <cstring> #include <iostream ...

  10. SOJ 2930_积木城堡

    [题意]若干个城堡,给定每个城堡的积木数及每块积木的棱长.从城堡中抽出积木使每块城堡高度相同,求最大高度 [分析]城堡的积木选择可以看成01背包问题,从最矮的城堡高度开始依次递减,求出使每个背包都能装 ...