Docs 菜单
Docs 主页
/
Atlas
/ / / /

自动补全

autocomplete

autocomplete 操作符会搜索包含来自非完整输入字符串的一系列字符的词或短语。您打算使用 autocomplete 操作符查询的字段必须使用集合索引定义中的 autocomplete 数据类型进行索引。要了解如何为自动完成配置索引,请参阅 如何为自动完成的字段编制索引。

注意

对于单个字符串中包含三个以上单词的查询,Atlas Search 可能会返回不准确的结果。

您可以将 autocomplete 运算符与“键入时搜索”应用程序一起使用,以在应用程序的搜索字段中输入字符时更加准确地预测单词。autocomplete 返回的结果包含根据自动完成索引定义中指定的标记化策略所预测的单词。

如果要使用 Atlas Search autocomplete 操作符来构建建议或下拉列表,我们建议您查询一组建议的搜索词或使用过去的搜索词来填充下拉列表。如果您创建了单独的建议搜索词集合,则可以在 Atlas Search 索引中定义同义词映射,以在集合中搜索准确或替代单词。您可以追踪搜索词并查看搜索词的指标以构建集合。

autocomplete 通过以下语法实现:

1{
2 $search: {
3 "index": "<index name>", // optional, defaults to "default"
4 "autocomplete": {
5 "query": "<search-string>",
6 "path": "<field-to-search>",
7 "tokenOrder": "any|sequential",
8 "fuzzy": <options>,
9 "score": <options>
10 }
11 }
12}
字段
类型
说明
必要性
默认

query

字符串或字符串数组

要搜索的一个或多个字符串。如果字符串中有多个词,Atlas Search 还会分别为字符串中的每个词查找匹配项。

path

字符串

要搜索的索引字段。该字段必须建立索引为 autocomplete 数据类型。要了解更多信息,请参阅如何为自动完成的字段编制索引。

autocomplete操作符不支持path 参数中的 multiwildcard (*) 选项。它也不支持将字段大量作为 path 值。

有关跨多个字段的 autocomplete 操作符查询的示例,请参阅跨多个字段搜索。

fuzzy

对象

启用模糊搜索。查找与搜索词相似的字符串。

no

fuzzy
.maxEdits

整型

匹配指定搜索词所需的最大单字符编辑数。值可以是 12

no

2

fuzzy
.prefixLength

整型

结果中每个术语开头必须完全匹配的字符数。

no

0

fuzzy
.maxExpansions

整型

生成和搜索变体的最大数量。此限制适用于每个令牌。

no

50

score

对象

要分配给匹配搜索词结果的分数。使用以下选项之一修改默认分数:

  • boost:将结果分数乘以给定数字。

  • constant:用给定数字替换结果分数。

  • function:用给定表达式替换结果分数。

autocomplete 以较低的分数保真度换取更快的查询执行速度。要学习;了解更多信息,请参阅对行为进行评分。

有关在查询中使用 score 的信息,请参阅对结果中的文档进行评分

no

tokenOrder

字符串

搜索令牌的顺序。值可以是以下之一:

any

表示查询中的标记可按任意顺序出现在文档中。结果包含令牌会按顺序和无顺序显示的文档。但是,令牌按顺序显示的结果的得分高于其他非连续值。

sequential

表示查询中的令牌必须彼此相邻,或按照查询中指定的顺序出现在文档中。结果只包含令牌依次出现的文档。

no

any

属于完全匹配的 autocomplete 运算符查询结果比非完全匹配的结果得分低。如果仅指定 autocomplete 已索引的令牌子字符串,Atlas Search 则无法确定查询字符串是否与索引的文本完全匹配。要提高完全匹配的得分,请尝试以下解决方法:

注意

以下解决方法无法保证在所有情况下精确匹配都能获得较高的分数。

  1. 将字段索引为自动完成字符串类型。

    autocomplete 字段也被索引为 string 时,Atlas Search autocomplete 会提高精确匹配度,从而提高精确匹配的分数。

  2. 使用复合操作符查询。

有关此解决方法的演示,请参阅 跨多个字段搜索。

以下示例使用 sample_mflix 数据库中的 movies 集合。如果在集群上加载了样本数据集,则可以创建用于自动完成的静态索引,并在集群上运行示例查询。

以下标签页包含 edgeGramrightEdgeGramnGram 分词器策略的示例索引定义。除了 autocomplete 类型以外,示例索引定义还包括 title 字段上的 stringstringFacet 类型。

1{
2 "mappings": {
3 "dynamic": false,
4 "fields": {
5 "title": [
6 {
7 "type": "stringFacet"
8 },
9 {
10 "type": "string"
11 },
12 {
13 "foldDiacritics": false,
14 "maxGrams": 7,
15 "minGrams": 3,
16 "tokenization": "edgeGram",
17 "type": "autocomplete"
18 }
19 ],
20 "plot": [
21 {
22 "type": "autocomplete",
23 "tokenization": "edgeGram",
24 "minGrams": 2,
25 "maxGrams": 15,
26 "foldDiacritics": true
27 }
28 ]
29 }
30 }
31}
1{
2 "mappings": {
3 "dynamic": false,
4 "fields": {
5 "title": [
6 {
7 "type": "stringFacet"
8 },
9 {
10 "type": "string"
11 },
12 {
13 "foldDiacritics": false,
14 "maxGrams": 7,
15 "minGrams": 3,
16 "tokenization": "rightEdgeGram",
17 "type": "autocomplete"
18 }
19 ],
20 "plot": [
21 {
22 "type": "autocomplete",
23 "tokenization": "rightEdgeGram",
24 "minGrams": 2,
25 "maxGrams": 15,
26 "foldDiacritics": true
27 }
28 ]
29 }
30 }
31}
1{
2 "mappings": {
3 "dynamic": false,
4 "fields": {
5 "title": [
6 {
7 "type": "stringFacet"
8 },
9 {
10 "type": "string"
11 },
12 {
13 "foldDiacritics": false,
14 "maxGrams": 7,
15 "minGrams": 3,
16 "tokenization": "nGram",
17 "type": "autocomplete"
18 }
19 ],
20 "plot": [
21 {
22 "type": "autocomplete",
23 "tokenization": "nGram",
24 "minGrams": 2,
25 "maxGrams": 15,
26 "foldDiacritics": true
27 }
28 ]
29 }
30 }
31}

➤ 使用 Select your language(选择您的语言)下拉菜单设置此页面上示例的语言。


Search Tester 中查看和编辑查询语法:

1

警告

导航改进正在进行中

我们目前正在推出改进的全新导航体验。如果以下步骤与Atlas用户界面中的视图不匹配,请参阅预览文档。

  1. 如果尚未显示,请从导航栏上的 Organizations 菜单中选择包含所需项目的组织。

  2. 如果尚未显示,请从导航栏的Projects菜单中选择所需的项目。

  3. 如果尚未出现,请单击侧边栏中的 Clusters(集群)。

    会显示集群页面。

2

您可以从侧边栏、 Data Explorer 或集群详细信息页面转到 Atlas Search 页面。

  1. 在侧边栏中,单击 Services 标题下的 Atlas Search

    如果没有集群,则请单击 Create cluster 来创建一个。要了解更多信息,请参阅创建集群

  2. 如果您的项目有多个集群,请从 Select cluster 下拉列表中选择要使用的集群,然后单击 Go to Atlas Search

    将显示 Atlas Search 页面。

  1. 单击集群的对应 Browse Collections 按钮。

  2. 展开数据库并选择集合。

  3. 单击该集合的 Search Indexes 标签页。

    将显示 Atlas Search 页面。

  1. 单击集群的名称。

  2. 单击 Atlas Search 标签页。

    将显示 Atlas Search 页面。

3
  1. 单击要查询的索引右侧的 Query 按钮。

  2. 单击Edit Query查看 JSON格式的默认查询语法示例。

mongosh 提示符下运行以下命令,以使用 sample_mflix 数据库:

use sample_mflix

要学习;了解如何在 mongosh 中运行以下查询,请参阅定义查询。

要学习;了解如何在MongoDB Compass中运行以下查询,请参阅定义查询。

要学习;了解如何使用MongoDB C#驾驶员运行以下查询,请参阅定义查询。

要学习;了解如何使用MongoDB Go驾驶员运行以下查询,请参阅定义查询。

要学习;了解如何使用MongoDB Java驾驶员运行以下查询,请参阅定义查询。

要学习;了解如何使用MongoDB Kotlin驾驶员运行以下查询,请参阅定义查询。

要学习;了解如何使用PyMongo驾驶员运行以下查询,请参阅定义查询。

下面的查询会搜索 title 字段中包含字符 off 的电影。

将以下查询复制并粘贴到 Query Editor 中,然后点击 Query Editor 中的 Search 按钮。

[
{
$search: {
autocomplete: {
path: "title",
query: "off"
}
}
}
]

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

db.movies.aggregate([
{
$search: {
"autocomplete": {
"path": "title",
"query": "off"
}
}
},
{
$limit: 10
},
{
$project: {
"_id": 0,
"title": 1
}
}
])

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

movies 集合的 Aggregations 标签页中,从下拉菜单中选择阶段并为该阶段添加查询,以配置以下每个管道阶段。单击 Add Stage 添加其他阶段。

管道阶段
查询

$search

{
"autocomplete": {
"query": "off",
"path": "title"
}
}

$limit

10

$project

{
"_id": 0,
"title": 1,
}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;
using MongoDB.Driver.Search;
public class AutocompleteBasicExample
{
private const string MongoConnectionString = "<connection-string>";
public static void Main(string[] args)
{
// allow automapping of the camelCase database fields to our MovieDocument
var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
// connect to your Atlas cluster
var mongoClient = new MongoClient(MongoConnectionString);
var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
// define and run pipeline
var results = moviesCollection.Aggregate()
.Search(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Title, "off"))
.Project<MovieDocument>(Builders<MovieDocument>.Projection
.Include(movie => movie.Title)
.Exclude(movie => movie.Id))
.Limit(10)
.ToList();
// print results
foreach (var movie in results)
{
Console.WriteLine(movie.ToJson());
}
}
}
[BsonIgnoreExtraElements]
public class MovieDocument
{
[BsonIgnoreIfDefault]
public ObjectId Id { get; set; }
public string Title { get; set; }
}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

package main
import (
"context"
"fmt"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func main() {
// connect to your Atlas cluster
client, err := mongo.Connect(options.Client().ApplyURI("<connection-string>"))
if err != nil {
panic(err)
}
defer client.Disconnect(context.TODO())
// set namespace
collection := client.Database("sample_mflix").Collection("movies")
// define pipeline stages
searchStage := bson.D{{Key: "$search", Value: bson.D{{Key: "autocomplete", Value: bson.D{{Key: "query", Value: "off"}, {Key: "path", Value: "title"}}}}}}
limitStage := bson.D{{Key: "$limit", Value: 10}}
projectStage := bson.D{{Key: "$project", Value: bson.D{{Key: "title", Value: 1}, {Key: "_id", Value: 0}}}}
// run pipeline
cursor, err := collection.Aggregate(context.TODO(), mongo.Pipeline{searchStage, limitStage, projectStage})
if err != nil {
panic(err)
}
// print results
var results []bson.D
if err = cursor.All(context.TODO(), &results); err != nil {
panic(err)
}
for _, result := range results {
fmt.Println(result)
}
}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import static com.mongodb.client.model.Aggregates.limit;
import static com.mongodb.client.model.Aggregates.project;
import static com.mongodb.client.model.Projections.excludeId;
import static com.mongodb.client.model.Projections.fields;
import static com.mongodb.client.model.Projections.include;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import java.util.Arrays;
public class AutocompleteBasicExample {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("sample_mflix");
MongoCollection<Document> collection = database.getCollection("movies");
// define pipeline
Document agg = new Document("$search", new Document("autocomplete", new Document("query", "off").append("path", "title")));
// run pipeline and print results
collection.aggregate(Arrays.asList(agg,
limit(10),
project(fields(excludeId(), include("title"))))).forEach(doc -> System.out.println(doc.toJson()));
}
}
}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

const { MongoClient } = require("mongodb");
// connect to your Atlas cluster
const uri =
"<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
await client.connect();
// set namespace
const database = client.db("sample_mflix");
const coll = database.collection("movies");
// define pipeline
const agg = [
{$search: {autocomplete: {query: "off", path: "title"}}},
{$limit: 10},
{$project: {_id: 0,title: 1}}
];
// run pipeline
const result = await coll.aggregate(agg);
// print results
await result.forEach((doc) => console.log(doc));
} finally {
await client.close();
}
}
run().catch(console.dir);

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import com.mongodb.client.model.Aggregates.limit
import com.mongodb.client.model.Aggregates.project
import com.mongodb.client.model.Projections.*
import com.mongodb.kotlin.client.coroutine.MongoClient
import kotlinx.coroutines.runBlocking
import org.bson.Document
fun main() {
val uri = "<connection-string>"
val mongoClient = MongoClient.create(uri)
val database = mongoClient.getDatabase("sample_mflix")
val collection = database.getCollection<Document>("movies")
runBlocking {
val agg = Document(
"\$search",
Document("autocomplete", Document("query", "off")
.append("path", "title"))
)
val resultsFlow = collection.aggregate<Document>(
listOf(
agg,
limit(10),
project(fields(excludeId(), include("title")))
)
)
resultsFlow.collect { println(it) }
}
mongoClient.close()
}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import pymongo
# connect to your Atlas cluster
client = pymongo.MongoClient('<connection-string>')
# define pipeline
pipeline = [
{"$search": {"autocomplete": {"query": "off", "path": "title"}}},
{"$limit": 10},
{"$project": {"_id": 0, "title": 1}},
]
# run pipeline
result = client["sample_mflix"]["movies"].aggregate(pipeline)
# print results
for i in result:
print(i)

注意

结果可能会有所不同

Atlas Search 根据自动完成类型的索引定义中配置的分词策略返回不同的结果。要了解更多信息,请参阅如何为自动完成的字段编制索引。

SCORE: 9.361787796020508 _id: "573a13b0f29313caabd355c8"
countries: Array
genres: Array
runtime: 100
...
title: "Off Beat"
SCORE: 9.068204879760742 _id: "573a13aaf29313caabd22a8c"
fullplot: "An 11-year-old girl watches her father come down with a crippling depr…"
imdb: Object
year: 2003
...
title: "Off the Map"
SCORE: 9.068204879760742 _id: "573a13bef29313caabd5d208"
plot: "With white Jewish lesbians for parents and two adopted brothers - one …"
genres: Array
runtime: 76
...
title: "Off and Running"
SCORE: 8.742463111877441 _id: "573a13bbf29313caabd5567"
countries: Array
genres: Array
runtime: 98
...
title: "Hands off Mississippi"
SCORE: 8.61273193359375 _id: "5573a1396f29313caabce4791"
plot: "Unable to deal with her parents, Jeannie Tyne runs away from home. Lar…"
genres: Array
runtime: 93
...
title: "Taking Off"
SCORE: 8.61273193359375 _id: "573a1399f29313caabced3c1"
plot: "A travelling theater group find so much action going on behind-the-sce…"
genres: Array
runtime: 101
...
title: "Noises Off..."
SCORE: 8.61273193359375 _id: "573a139af29313caabcefc73"
fullplot: "In existence for a hundred years, Grimley Colliery Brass band is as ol…"
imdb: Object
year: 1996
...
title: "Brassed Off"
SCORE: 8.61273193359375 _id: "573a139af29313caabcf08f5"
fullplot: "Sean Archer, a very tough, rugged FBI Agent. Who is still grieving for…"
imdb: Object
year: 1997
...
title: "Face/Off"
SCORE: 8.603004455566406 _id: "573a13a9f29313caabd1ea36"
fullplot: "Three unlikely, unsuspecting souls who come face-to-face with that mom…"
imdb: Object
year: 2004
...
title: "Benji: Off the Leash!"
SCORE: 7.953945159912109 _id: "573a139af29313caabcf037c"
plot: "Desperation drives four inner-city women (Queen Latifah, Jada Pinkett …"
genres: Array
runtime: 123
...
title: "Set it Off"
SCORE: 9.81808090209961 _id: "5573a1396f29313caabce4791"
plot: "Unable to deal with her parents, Jeannie Tyne runs away from home. Lar…"
genres: Array
runtime: 93
...
title: "Taking Off"
SCORE: 9.81808090209961 _id: "573a1399f29313caabced3c1"
plot: "A travelling theater group find so much action going on behind-the-sce…"
genres: Array
runtime: 101
...
title: "Noises Off..."
SCORE: 9.81808090209961 _id: "573a139af29313caabcefc73"
fullplot: "In existence for a hundred years, Grimley Colliery Brass band is as ol…"
imdb: Object
year: 1996
...
title: "Brassed Off"
SCORE: 9.81808090209961 _id: "573a139af29313caabcf08f5"
fullplot: "Sean Archer, a very tough, rugged FBI Agent. Who is still grieving for…"
imdb: Object
year: 1997
...
title: "Face/Off"
SCORE: 9.544584274291992 _id: "573a139af29313caabcf037c"
plot: "Desperation drives four inner-city women (Queen Latifah, Jada Pinkett …"
genres: Array
runtime: 123
...
title: "Set it Off"
SCORE: 9.191947937011719 _id: "573a13bbf29313caabd5567"
countries: Array
genres: Array
runtime: 98
...
title: "Hands off Mississippi"
SCORE: 9.074413299560547 _id: "573a1398f29313caabce9f28"
plot: "A high school wise guy is determined to have a day off from school, de…"
genres: Array
runtime: 103
...
title: "Ferris Bueller's Day Off"
SCORE: 9.007184982299805 _id: "573a13b0f29313caabd355c8"
countries: Array
genres: Array
runtime: 100
...
title: "Off Beat"
SCORE: 8.700296401977539 _id: "573a13a9f29313caabd1ea36"
fullplot: "Three unlikely, unsuspecting souls who come face-to-face with that mom…"
imdb: Object
year: 2004
...
title: "Benji: Off the Leash!"
SCORE: 8.33833122253418 _id: "573a13aaf29313caabd22a8c"
fullplot: "An 11-year-old girl watches her father come down with a crippling depr…"
imdb: Object
year: 2003
...
title: "Off the Map"
SCORE: 5.802560806274414 _id: “573a1396f29313caabce47f4”
countries: Array
genres: Array
runtime: 98
...
title: "Come Have Coffee with Us"
SCORE: 5.790548801422119 _id: "573a13d1f29313caabd90811"
plot: "From pagan re-enactors to failed communes, black metal festivals to Ar…"
genres: Array
runtime: 98
...
title: "A Spell to Ward Off the Darkness"
SCORE: 5.7726240158081055 _id: "573a13f3f29313caabddeb07"
plot: "Turkey in the 1960s and 70s was one of the biggest producers of film i…"
genres: Array
runtime: 96
...
title: "Remake, Remix, Rip-Off: About Copy Culture & Turkish Pop Cinema"
SCORE: 5.749281883239746 _id: "573a13a9f29313caabd1ea36"
fullplot: "Three unlikely, unsuspecting souls who come face-to-face with that mom…"
imdb: Object
year: 2004
...
title: "Benji: Off the Leash!"
SCORE: 5.749281883239746 _id: "573a13d4f29313caabd98488"
fullplot: "This tragicomedy is a self-ironic portrait of a young man who drops ou…"
imdb: Object
year: 2012
...
title: "A Coffee in Berlin"
SCORE: 5.74220085144043 _id: “573a1397f29313caabce863f”
fullplot: "Zack Mayo is a young man who has signed up for Navy Aviation Officer C…"
imdb: Object
year: 1982
...
title: "An Officer and a Gentleman"
SCORE: 5.671174049377441 _id: “573a1398f29313caabce987c”
plot: "After the end of the Dirty War, a high school teacher sets out to find…"
genres: Array
runtime: 112
...
title: "The Official Story"
SCORE: 5.671174049377441 _id: “573a13a5f29313caabd14c36”
plot: "The first days of WWI. Adrien, a young and handsome lieutenant, is wou…"
genres: Array
runtime: 135
...
title: "The Officer's Ward"
SCORE: 5.671174049377441 _id: "573a13bbf29313caabd5567"
countries: Array
genres: Array
runtime: 98
...
title: "Hands off Mississippi"
SCORE: 5.534632682800293 _id: "573a1395f29313caabce18c9"
plot: "In this "Romeo and Juliet" inspired Cold War satire starring, written …"
genres: Array
runtime: 103
...
title: "Romanoff and Juliet"

Search Tester 可能不会显示其所返回文档的所有字段。要查看所有字段,包括在查询路径中指定的字段,请展开结果中的文档。

1{ title: 'Off Beat' },
2{ title: 'Off the Map' },
3{ title: 'Off and Running' },
4{ title: 'Hands off Mississippi' },
5{ title: 'Taking Off' },
6{ title: 'Noises Off...' },
7{ title: 'Brassed Off' },
8{ title: 'Face/Off' },
9{ title: 'Benji: Off the Leash!' },
10{ title: 'Set It Off' }

在上述结果中,字符 off 出现在所有标题中的某个单词的左侧。

1{ title: 'Taking Off' }
2{ title: 'Noises Off...' }
3{ title: 'Brassed Off' }
4{ title: 'Face/Off' }
5{ title: 'Set It Off' }
6{ title: 'Hands off Mississippi' }
7{ title: "Ferris Bueller's Day Off" }
8{ title: 'Off Beat' }
9{ title: 'Benji: Off the Leash!' }
10{ title: 'Off the Map' }

在上述结果中,字符 off 出现在所有标题中的某个单词的右侧。

1{ title: 'Come Have Coffee with Us' },
2{ title: 'A Spell to Ward Off the Darkness' },
3{ title: 'Remake, Remix, Rip-Off: About Copy Culture & Turkish Pop Cinema' },
4{ title: 'Benji: Off the Leash!' },
5{ title: 'A Coffee in Berlin' },
6{ title: 'An Officer and a Gentleman' },
7{ title: 'The Official Story' },
8{ title: "The Officer's Ward" },
9{ title: 'Hands off Mississippi' },
10{ title: 'Romanoff and Juliet' }

在上述结果中,字符 off 出现在标题中的不同位置。

1{ title: 'Off Beat' },
2{ title: 'Off the Map' },
3{ title: 'Off and Running' },
4{ title: 'Hands off Mississippi' },
5{ title: 'Taking Off' },
6{ title: 'Noises Off...' },
7{ title: 'Brassed Off' },
8{ title: 'Face/Off' },
9{ title: 'Benji: Off the Leash!' },
10{ title: 'Set It Off' }

在上述结果中,字符 off 出现在所有标题中的某个单词的左侧。

1{ title: 'Taking Off' }
2{ title: 'Noises Off...' }
3{ title: 'Brassed Off' }
4{ title: 'Face/Off' }
5{ title: 'Set It Off' }
6{ title: 'Hands off Mississippi' }
7{ title: "Ferris Bueller's Day Off" }
8{ title: 'Off Beat' }
9{ title: 'Benji: Off the Leash!' }
10{ title: 'Off the Map' }

在上述结果中,字符 off 出现在所有标题中的某个单词的右侧。

1{ title: 'Come Have Coffee with Us' },
2{ title: 'A Spell to Ward Off the Darkness' },
3{ title: 'Remake, Remix, Rip-Off: About Copy Culture & Turkish Pop Cinema' },
4{ title: 'Benji: Off the Leash!' },
5{ title: 'A Coffee in Berlin' },
6{ title: 'An Officer and a Gentleman' },
7{ title: 'The Official Story' },
8{ title: "The Officer's Ward" },
9{ title: 'Hands off Mississippi' },
10{ title: 'Romanoff and Juliet' }

在上述结果中,字符 off 出现在标题中的不同位置。

1{ "title": "Off Beat" }
2{ "title": "Off the Map" }
3{ "title": "Off and Running" }
4{ "title": "Hands off Mississippi" }
5{ "title": "Taking Off" }
6{ "title": "Noises Off..." }
7{ "title": "Brassed Off" }
8{ "title": "Face/Off" }
9{ "title": "Benji: Off the Leash!" }
10{ "title": "Set It Off" }

在上述结果中,字符 off 出现在所有标题中的某个单词的左侧。

1{ "title" : "Taking Off" }
2{ "title" : "Noises Off..." }
3{ "title" : "Brassed Off" }
4{ "title" : "Face/Off" }
5{ "title" : "Set It Off" }
6{ "title" : "Hands off Mississippi" }
7{ "title" : "Ferris Bueller's Day Off" }
8{ "title" : "Off Beat" }
9{ "title" : "Benji: Off the Leash!" }
10{ "title" : "Off the Map" }

在上述结果中,字符 off 出现在所有标题中的某个单词的右侧。

1{ "title" : "Come Have Coffee with Us" }
2{ "title" : "A Spell to Ward Off the Darkness" }
3{ "title" : "Remake, Remix, Rip-Off: About Copy Culture & Turkish Pop Cinema" }
4{ "title" : "Benji: Off the Leash!" }
5{ "title" : "A Coffee in Berlin" }
6{ "title" : "An Officer and a Gentleman" }
7{ "title" : "The Official Story" }
8{ "title" : "The Officer's Ward" }
9{ "title" : "Hands off Mississippi" }
10{ "title" : "Romanoff and Juliet" }

在上述结果中,字符 off 出现在标题中的不同位置。

1[{title Off Beat}]
2[{title Off the Map}]
3[{title Off and Running}]
4[{title Hands off Mississippi}]
5[{title Taking Off}]
6[{title Noises Off...}]
7[{title Brassed Off}]
8[{title Face/Off}]
9[{title Benji: Off the Leash!}]
10[{title Set It Off}]

在上述结果中,字符 off 出现在所有标题中的某个单词的左侧。

1[{title Taking Off}]
2[{title Noises Off...}]
3[{title Brassed Off}]
4[{title Face/Off}]
5[{title Set It Off}]
6[{title Hands off Mississippi}]
7[{title Ferris Bueller's Day Off}]
8[{title Off Beat}]
9[{title Benji: Off the Leash!}]
10[{title Off the Map}]

在上述结果中,字符 off 出现在所有标题中的某个单词的右侧。

1[{title Come Have Coffee with Us}]
2[{title A Spell to Ward Off the Darkness}]
3[{title Remake, Remix, Rip-Off: About Copy Culture & Turkish Pop Cinema}]
4[{title Benji: Off the Leash!}]
5[{title A Coffee in Berlin}]
6[{title An Officer and a Gentleman}]
7[{title The Official Story}]
8[{title The Officer's Ward}]
9[{title Hands off Mississippi}]
10[{title Romanoff and Juliet}]

在上述结果中,字符 off 出现在标题中的不同位置。

1{"title": "Off Beat"}
2{"title": "Off the Map"}
3{"title": "Off and Running"}
4{"title": "Hands off Mississippi"}
5{"title": "Taking Off"}
6{"title": "Noises Off..."}
7{"title": "Brassed Off"}
8{"title": "Face/Off"}
9{"title": "Benji: Off the Leash!"}
10{"title": "Set It Off"}

在上述结果中,字符 off 出现在所有标题中的某个单词的左侧。

1{"title": "Taking Off"}
2{"title": "Noises Off..."}
3{"title": "Brassed Off"}
4{"title": "Face/Off"}
5{"title": "Set It Off"}
6{"title": "Hands off Mississippi"}
7{"title": "Ferris Bueller's Day Off"}
8{"title": "Off Beat"}
9{"title": "Benji: Off the Leash!"}
10{"title": "Off the Map"}

在上述结果中,字符 off 出现在所有标题中的某个单词的右侧。

1{"title": "Come Have Coffee with Us"}
2{"title": "A Spell to Ward Off the Darkness"}
3{"title": "Remake, Remix, Rip-Off: About Copy Culture & Turkish Pop Cinema"}
4{"title": "Benji: Off the Leash!"}
5{"title": "A Coffee in Berlin"}
6{"title": "An Officer and a Gentleman"}
7{"title": "The Official Story"}
8{"title": "The Officer's Ward"}
9{"title": "Hands off Mississippi"}
10{"title": "Romanoff and Juliet"}

在上述结果中,字符 off 出现在标题中的不同位置。

1Document{{title=Off Beat}}
2Document{{title=Off the Map}}
3Document{{title=Off and Running}}
4Document{{title=Hands off Mississippi}}
5Document{{title=Taking Off}}
6Document{{title=Face/Off}}
7Document{{title=Noises Off...}}
8Document{{title=Brassed Off}}
9Document{{title=Benji: Off the Leash!}}
10Document{{title=Set It Off}}

在上述结果中,字符 off 出现在所有标题中的某个单词的左侧。

1Document{{title=Noises Off...}}
2Document{{title=Taking Off}}
3Document{{title=Brassed Off}}
4Document{{title=Face/Off}}
5Document{{title=Set It Off}}
6Document{{title=Hands off Mississippi}}
7Document{{title=Ferris Bueller's Day Off}}
8Document{{title=Off Beat}}
9Document{{title=Benji: Off the Leash!}}
10Document{{title=Off and Running}}

在上述结果中,字符 off 出现在所有标题中的某个单词的右侧。

1Document{{title=Taking Off}}
2Document{{title=Noises Off...}}
3Document{{title=Brassed Off}}
4Document{{title=Face/Off}}
5Document{{title=Off Beat}}
6Document{{title=Hands off Mississippi}}
7Document{{title=Off the Map}}
8Document{{title=Set It Off}}
9Document{{title=Off and Running}}
10Document{{title=Benji: Off the Leash!}}

在上述结果中,字符 off 出现在标题中的不同位置。

1{ title: 'Off Beat' }
2{ title: 'Off the Map' }
3{ title: 'Off and Running' }
4{ title: 'Hands off Mississippi' }
5{ title: 'Taking Off' }
6{ title: 'Noises Off...' }
7{ title: 'Brassed Off' }
8{ title: 'Face/Off' }
9{ title: 'Benji: Off the Leash!' }
10{ title: 'Set It Off' }

在上述结果中,字符 off 出现在所有标题中的某个单词的左侧。

1{ title: 'Taking Off' }
2{ title: 'Noises Off...' }
3{ title: 'Brassed Off' }
4{ title: 'Face/Off' }
5{ title: 'Set It Off' }
6{ title: 'Hands off Mississippi' }
7{ title: "Ferris Bueller's Day Off" }
8{ title: 'Off Beat' }
9{ title: 'Benji: Off the Leash!' }
10{ title: 'Off the Map' }

在上述结果中,字符 off 出现在所有标题中的某个单词的右侧。

1{ title: 'Come Have Coffee with Us' }
2{ title: 'A Spell to Ward Off the Darkness' }
3{ title: 'Remake, Remix, Rip-Off: About Copy Culture & Turkish Pop Cinema' }
4{ title: 'Benji: Off the Leash!' }
5{ title: 'A Coffee in Berlin' }
6{ title: 'An Officer and a Gentleman' }
7{ title: 'The Official Story' }
8{ title: "The Officer's Ward" }
9{ title: 'Hands off Mississippi' }
10{ title: 'Romanoff and Juliet' }

在上述结果中,字符 off 出现在标题中的不同位置。

1{'title': 'Off Beat'}
2{'title': 'Off the Map'}
3{'title': 'Off and Running'}
4{'title': 'Hands off Mississippi'}
5{'title': 'Taking Off'}
6{'title': 'Noises Off...'}
7{'title': 'Brassed Off'}
8{'title': 'Face/Off'}
9{'title': 'Benji: Off the Leash!'}
10{'title': 'Set It Off'}

在上述结果中,字符 off 出现在所有标题中的某个单词的左侧。

1{'title': 'Taking Off'}
2{'title': 'Noises Off...'}
3{'title': 'Brassed Off'}
4{'title': 'Face/Off'}
5{'title': 'Set It Off'}
6{'title': 'Hands off Mississippi'}
7{'title': "Ferris Bueller's Day Off"}
8{'title': 'Off Beat'}
9{'title': 'Benji: Off the Leash!'}
10{'title': 'Off the Map'}

在上述结果中,字符 off 出现在所有标题中的某个单词的右侧。

1{'title': 'Come Have Coffee with Us'}
2{'title': 'A Spell to Ward Off the Darkness'}
3{'title': 'Remake, Remix, Rip-Off: About Copy Culture & Turkish Pop Cinema'}
4{'title': 'Benji: Off the Leash!'}
5{'title': 'A Coffee in Berlin'}
6{'title': 'An Officer and a Gentleman'}
7{'title': 'The Official Story'}
8{'title': "The Officer's Ward"}
9{'title': 'Hands off Mississippi'}
10{'title': 'Romanoff and Juliet'}

在上述结果中,字符 off 出现在标题中的不同位置。

下面的查询会搜索 title 字段中包含字符 pre 的电影。查询使用:

字段

说明

maxEdits

表示查询字符串 pre 中只允许有一个字符变体,以便将查询与文档中的单词匹配。

prefixLength

表示将查询与文档中的单词进行匹配时,查询字符串 pre 中的第一个字符无法更改。

maxExpansions

表示将查询字符串与文档中的单词进行匹配时,最多可以为 pre 考虑 256 个相似的术语。

将以下查询复制并粘贴到 Query Editor 中,然后点击 Query Editor 中的 Search 按钮。

[
{
$search: {
autocomplete: {
path: "title",
query: "pre",
fuzzy: {
maxEdits: 1,
prefixLength: 1,
maxExpansions: 256
}
}
}
}
]
db.movies.aggregate([
{
$search: {
"autocomplete": {
"path": "title",
"query": "pre",
"fuzzy": {
"maxEdits": 1,
"prefixLength": 1,
"maxExpansions": 256
}
}
}
},
{
$limit: 10
},
{
$project: {
"_id": 0,
"title": 1
}
}
])

movies 集合的 Aggregations 标签页中,从下拉菜单中选择阶段并为该阶段添加查询,以配置以下每个管道阶段。单击 Add Stage 添加其他阶段。

管道阶段
查询

$search

{
"autocomplete": {
"query": "pre",
"path": "title",
"fuzzy": {
"maxEdits": 1,
"prefixLength": 1,
"maxExpansions": 256
}
}
}

$limit

10

$project

{
"_id": 0,
"title": 1,
}
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;
using MongoDB.Driver.Search;
public class AutocompleteFuzzyExample
{
private const string MongoConnectionString = "<connection-string>";
public static void Main(string[] args)
{
// allow automapping of the camelCase database fields to our MovieDocument
var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
// connect to your Atlas cluster
var mongoClient = new MongoClient(MongoConnectionString);
var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
// define fuzzy options
SearchFuzzyOptions fuzzyOptions = new SearchFuzzyOptions()
{
MaxEdits = 1,
PrefixLength = 1,
MaxExpansions = 256
};
// define and run pipeline
var results = moviesCollection.Aggregate()
.Search(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Title, "pre", fuzzy: fuzzyOptions))
.Project<MovieDocument>(Builders<MovieDocument>.Projection
.Include(movie => movie.Title)
.Exclude(movie => movie.Id))
.Limit(10)
.ToList();
// print results
foreach (var movie in results)
{
Console.WriteLine(movie.ToJson());
}
}
}
[BsonIgnoreExtraElements]
public class MovieDocument
{
[BsonIgnoreIfDefault]
public ObjectId Id { get; set; }
public string Title { get; set; }
}
package main
import (
"context"
"fmt"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func main() {
// connect to your Atlas cluster
client, err := mongo.Connect(options.Client().ApplyURI("<connection-string>"))
if err != nil {
panic(err)
}
defer client.Disconnect(context.TODO())
// set namespace
collection := client.Database("sample_mflix").Collection("movies")
// define pipeline stages
searchStage := bson.D{{Key: "$search", Value: bson.D{{Key: "autocomplete", Value: bson.D{{Key: "query", Value: "pre"}, {Key: "path", Value: "title"}, {Key: "fuzzy", Value: bson.D{{Key: "maxEdits", Value: 1}, {Key: "prefixLength", Value: 1}, {Key: "maxExpansions", Value: 256}}}}}}}}
limitStage := bson.D{{Key: "$limit", Value: 10}}
projectStage := bson.D{{Key: "$project", Value: bson.D{{Key: "title", Value: 1}, {Key: "_id", Value: 0}}}}
// run pipeline
cursor, err := collection.Aggregate(context.TODO(), mongo.Pipeline{searchStage, limitStage, projectStage})
if err != nil {
panic(err)
}
// print results
var results []bson.D
if err = cursor.All(context.TODO(), &results); err != nil {
panic(err)
}
for _, result := range results {
fmt.Println(result)
}
}
import static com.mongodb.client.model.Aggregates.limit;
import static com.mongodb.client.model.Aggregates.project;
import static com.mongodb.client.model.Projections.excludeId;
import static com.mongodb.client.model.Projections.fields;
import static com.mongodb.client.model.Projections.include;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import java.util.Arrays;
public class AutocompleteFuzzyExample {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("sample_mflix");
MongoCollection<Document> collection = database.getCollection("movies");
// define pipeline
Document agg = new Document("$search", new Document("autocomplete",
new Document("query", "pre")
.append("path", "title")
.append("fuzzy", new Document("maxEdits", 1).append("prefixLength", 1).append("maxExpansions", 256))));
// run pipeline and print results
collection.aggregate(Arrays.asList(agg,
limit(10),
project(fields(excludeId(), include("title"))))).forEach(doc -> System.out.println(doc.toJson()));
}
}
}
import com.mongodb.client.model.Aggregates.limit
import com.mongodb.client.model.Aggregates.project
import com.mongodb.client.model.Projections.*
import com.mongodb.kotlin.client.coroutine.MongoClient
import kotlinx.coroutines.runBlocking
import org.bson.Document
fun main() {
val uri = "<connection-string>"
val mongoClient = MongoClient.create(uri)
val database = mongoClient.getDatabase("sample_mflix")
val collection = database.getCollection<Document>("movies")
runBlocking {
val agg = Document(
"\$search",
Document("autocomplete", Document("query", "pre")
.append("path", "title")
.append("fuzzy", Document("maxEdits", 1)
.append("prefixLength", 1)
.append("maxExpansions", 256))
)
)
val resultsFlow = collection.aggregate<Document>(
listOf(
agg,
limit(10),
project(fields(excludeId(), include("title")))
)
)
resultsFlow.collect { println(it) }
}
mongoClient.close()
}
const { MongoClient } = require("mongodb");
// connect to your Atlas cluster
const uri =
"<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
await client.connect();
// set namespace
const database = client.db("sample_mflix");
const coll = database.collection("movies");
// define pipeline
const agg = [
{$search: {autocomplete: {query: "pre", path: "title", fuzzy: {"maxEdits": 1, "prefixLength": 1, "maxExpansions": 256}}}},
{$limit: 10},
{$project: {_id: 0,title: 1}}
];
// run pipeline
const result = await coll.aggregate(agg);
// print results
await result.forEach((doc) => console.log(doc));
} finally {
await client.close();
}
}
run().catch(console.dir);
import pymongo
# connect to your Atlas cluster
client = pymongo.MongoClient('<connection-string>')
# define pipeline
pipeline = [
{"$search": {"autocomplete": {"query": "pre", "path": "title", "fuzzy": {"maxEdits": 1, "prefixLength": 1, "maxExpansions": 256}}}},
{"$limit": 10},
{"$project": {"_id": 0, "title": 1}},
]
# run pipeline
result = client["sample_mflix"]["movies"].aggregate(pipeline)
# print results
for i in result:
print(i)

注意

结果可能会有所不同

Atlas Search 根据自动完成类型的索引定义中配置的分词策略返回不同的结果。要了解更多信息,请参阅如何为自动完成的字段编制索引。

SCORE: 1 _id: “573a1390f29313caabcd5293”
plot: "Young Pauline is left a lot of money when her wealthy uncle dies. Howe…"
genres: Array
runtime: 199
...
title: "The Perils of Pauline"
SCORE: 1 _id: “573a1391f29313caabcd9458”
plot: "A young artist draws a face at a canvas on his easel. Suddenly the mou…"
genres: Array
rated: "UNRATED"
...
title: "The Blood of a Poet"
SCORE: 1 _id: “573a1392f29313caabcda09b”
plot: "Tells how King Henry VIII came to marry five more times after his divo…"
genres: Array
runtime: 97
...
title: "The Private Life of Henry VIII."
SCORE: 1 _id: “573a1392f29313caabcda556”
plot: "What do women want? Don Juan is aging. He's arrived secretly in Sevill…"
genres: Array
runtime: 89
...
title: "The Private Life of Don Juan"
SCORE: 1 _id: “573a1392f29313caabcdaee0”
plot: "The story of Dr. Samuel Mudd, who was imprisoned after innocently trea…"
genres: Array
runtime: 96
...
title: "The Prisoner of Shark Island"
SCORE: 1 _id: “573a1392f29313caabcdb3f2”
plot: "Two lookalike boys, one a poor street kid and the other a prince, exch…"
genres: Array
runtime: 118
...
title: "The Prince and the Pauper"
SCORE: 1 _id: “573a1392f29313caabcdb3f4”
plot: "An Englishman on a Ruritarian holiday must impersonate the king when t…"
genres: Array
runtime: 101
...
title: "The Prisoner of Zenda"
SCORE: 1 _id: “573a1392f29313caabcdb505”
plot: "After the death of her husband, Christine realizes she has possibly wa…"
genres: Array
runtime: 144
...
title: "Dance Program"
SCORE: 1 _id: “573a1393f29313caabcdca58”
plot: "While traveling in France during the Nazi invasion of 1940, an English…"
genres: Array
runtime: 87
...
title: "The Pied Piper"
SCORE: 1 _id: “573a1393f29313caabcdca76”
plot: "The official World War II US Government film statement defining the va…"
genres: Array
runtime: 87
...
title: "Prelude to War"
SCORE: 1 _id: “573a1390f29313caabcd5ea4”
plot: "A District Attorney's outspoken stand on abortion gets him in trouble …"
genres: Array
runtime: 62
...
title: "Where Are My Children?"
SCORE: 1 _id: “573a1391f29313caabcd70b4”
plot: "An extended family split up in France and Germany find themselves on o…"
genres: Array
runtime: 150
...
title: "The Four Horsemen of the Apocalypse"
SCORE: 1 _id: “573a1391f29313caabcd7850”
plot: "In fifteenth century Paris, the brother of the archdeacon plots with t…"
genres: Array
runtime: 133
...
title: "The Hunchback of Notre Dame"
SCORE: 1 _id: “573a1391f29313caabcd8cbd”
plot: "A young lady from Georgia goes to Hollywood in the hopes of becoming a…"
genres: Array
runtime: 83
...
title: "Show People"
SCORE: 1 _id: “573a1392f29313caabcd9df7”
plot: "A young American man is transported back to London in the time of the …"
genres: Array
runtime: 84
...
title: "Berkeley Square"
SCORE: 1 _id: “573a1392f29313caabcda7fb”
plot: "An entertainer impersonates a look-alike banker, causing comic confusi…"
genres: Array
runtime: 82
...
title: "Folies Bergère de Paris"
SCORE: 1 _id: “573a1393f29313caabcdc4a2”
plot: "Boxer Joe Pendleton dies 50 years too soon due to a heavenly mistake, …"
genres: Array
runtime: 94
...
title: "Here Comes Mr. Jordan"
SCORE: 1 _id: “573a1393f29313caabcdc814”
plot: "An American man marries a Serbian immigrant who fears that she will tu…"
genres: Array
runtime: 73
...
title: "Cat People"
SCORE: 1 _id: “573a1393f29313caabcdc87b”
plot: "Mail author for translation. Kodos hegycsucsok, fekete fenyvesek vilag…"
genres: Array
runtime: 88
...
title: "People on the Alps"
SCORE: 1 _id: “573a1393f29313caabcdcd39”
plot: "A soldier falls for a chorus girl and then experiences trouble when he…"
genres: Array
runtime: 103
...
title: "The Gang's All Here"
SCORE: 1 _id: “573a1390f29313caabcd5293”
plot: "Young Pauline is left a lot of money when her wealthy uncle dies. Howe…"
genres: Array
runtime: 199
...
title: "The Perils of Pauline"
SCORE: 1 _id: “573a1390f29313caabcd5967”
plot: "An intrepid reporter and his loyal friend battle a bizarre secret soci…"
genres: Array
runtime: 399
...
title: "Les vampires"
SCORE: 1 _id: “573a1391f29313caabcd6ea2”
plot: "The simple-minded son of a rich financier must find his own way in the…"
genres: Array
runtime: 77
...
title: "The Saphead"
SCORE: 1 _id: “573a1391f29313caabcd70b4”
plot: "An extended family split up in France and Germany find themselves on o…"
genres: Array
runtime: 150
...
title: "The Four Horsemen of the Apocalypse"
SCORE: 1 _id: “573a1391f29313caabcd7b98”
plot: "A bitter clown endeavors to rescue the young woman he loves from the l…"
genres: Array
runtime: 95
...
title: "He Who Gets Slapped"
SCORE: 1 _id: “573a1391f29313caabcd806b”
plot: "A mad, disfigured composer seeks love with a lovely young opera singer…"
genres: Array
runtime: 93
...
title: "The Phantom of the Opera"
SCORE: 1 _id: “573a1391f29313caabcd8cbd”
plot: "A young lady from Georgia goes to Hollywood in the hopes of becoming a…"
genres: Array
runtime: 83
...
title: "Show People"
SCORE: 1 _id: “573a1391f29313caabcd9458”
plot: "A young artist draws a face at a canvas on his easel. Suddenly the mou…"
genres: Array
rated: "UNRATED"
...
title: "The Blood of a Poet"
SCORE: 1 _id: “573a1391f29313caabcd9651”
plot: "In London at the turn of the century, the bandit Mack the Knife marrie…"
genres: Array
runtime: 112
...
title: "The 3 Penny Opera"
SCORE: 1 _id: “573a1392f29313caabcd9caa”
plot: "Many passengers on the Shanghai Express are more concerned that the no…"
genres: Array
runtime: 82
...
title: "Shanghai Express"

Search Tester 可能不会显示其所返回文档的所有字段。要查看所有字段,包括在查询路径中指定的字段,请展开结果中的文档。

1{ title: 'The Perils of Pauline' },
2{ title: 'The Blood of a Poet' },
3{ title: 'The Private Life of Henry VIII.' },
4{ title: 'The Private Life of Don Juan' },
5{ title: 'The Prisoner of Shark Island' },
6{ title: 'The Prince and the Pauper' },
7{ title: 'The Prisoner of Zenda' },
8{ title: 'Dance Program' },
9{ title: 'The Pied Piper' },
10{ title: 'Prelude to War' }

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词左侧。

1{ title: 'Where Are My Children?' }
2{ title: 'The Four Horsemen of the Apocalypse' }
3{ title: 'The Hunchback of Notre Dame' }
4{ title: 'Show People' }
5{ title: 'Berkeley Square' }
6{ title: 'Folies Bergère de Paris' }
7{ title: 'Here Comes Mr. Jordan' }
8{ title: 'Cat People' }
9{ title: 'People on the Alps' }
10{ title: "The Gang's All Here" }

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词右侧。

1{ title: 'The Perils of Pauline' }
2{ title: 'Les vampires' }
3{ title: 'The Saphead' }
4{ title: 'The Four Horsemen of the Apocalypse' }
5{ title: 'He Who Gets Slapped' }
6{ title: 'The Phantom of the Opera' }
7{ title: 'Show People' }
8{ title: 'The Blood of a Poet' }
9{ title: 'The 3 Penny Opera' }
10{ title: 'Shanghai Express' }

这些结果显示了针对字符串预测的单词,并在标题单词的不同位置修改了一个字符。

1{ title: 'The Perils of Pauline' },
2{ title: 'The Blood of a Poet' },
3{ title: 'The Private Life of Henry VIII.' },
4{ title: 'The Private Life of Don Juan' },
5{ title: 'The Prisoner of Shark Island' },
6{ title: 'The Prince and the Pauper' },
7{ title: 'The Prisoner of Zenda' },
8{ title: 'Dance Program' },
9{ title: 'The Pied Piper' },
10{ title: 'Prelude to War' }

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词左侧。

1{ title: 'Where Are My Children?' }
2{ title: 'The Four Horsemen of the Apocalypse' }
3{ title: 'The Hunchback of Notre Dame' }
4{ title: 'Show People' }
5{ title: 'Berkeley Square' }
6{ title: 'Folies Bergère de Paris' }
7{ title: 'Here Comes Mr. Jordan' }
8{ title: 'Cat People' }
9{ title: 'People on the Alps' }
10{ title: "The Gang's All Here" }

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词右侧。

1{ title: 'The Perils of Pauline' }
2{ title: 'Les vampires' }
3{ title: 'The Saphead' }
4{ title: 'The Four Horsemen of the Apocalypse' }
5{ title: 'He Who Gets Slapped' }
6{ title: 'The Phantom of the Opera' }
7{ title: 'Show People' }
8{ title: 'The Blood of a Poet' }
9{ title: 'The 3 Penny Opera' }
10{ title: 'Shanghai Express' }

这些结果显示了针对字符串预测的单词,并在标题单词的不同位置修改了一个字符。

1{ "title" : "The Perils of Pauline" }
2{ "title" : "The Blood of a Poet" }
3{ "title" : "The Private Life of Henry VIII." }
4{ "title" : "The Private Life of Don Juan" }
5{ "title" : "The Prisoner of Shark Island" }
6{ "title" : "The Prince and the Pauper" }
7{ "title" : "The Prisoner of Zenda" }
8{ "title" : "Dance Program" }
9{ "title" : "The Pied Piper" }
10{ "title" : "Prelude to War" }

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词左侧。

1{ "title" : "Where Are My Children?" }
2{ "title" : "The Four Horsemen of the Apocalypse" }
3{ "title" : "The Hunchback of Notre Dame" }
4{ "title" : "Show People" }
5{ "title" : "Berkeley Square" }
6{ "title" : "Folies Bergère de Paris" }
7{ "title" : "Here Comes Mr. Jordan" }
8{ "title" : "Cat People" }
9{ "title" : "People on the Alps" }
10{ "title" : "The Gang's All Here" }

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词右侧。

1{ "title" : "The Perils of Pauline" }
2{ "title" : "Les vampires" }
3{ "title" : "The Saphead" }
4{ "title" : "The Four Horsemen of the Apocalypse" }
5{ "title" : "He Who Gets Slapped" }
6{ "title" : "The Phantom of the Opera" }
7{ "title" : "Show People" }
8{ "title" : "The Blood of a Poet" }
9{ "title" : "The 3 Penny Opera" }
10{ "title" : "Shanghai Express" }

这些结果显示了针对字符串预测的单词,并在标题单词的不同位置修改了一个字符。

1[{title The Perils of Pauline}]
2[{title The Blood of a Poet}]
3[{title The Private Life of Henry VIII.}]
4[{title The Private Life of Don Juan}]
5[{title The Prisoner of Shark Island}]
6[{title The Prince and the Pauper}]
7[{title The Prisoner of Zenda}]
8[{title Dance Program}]
9[{title The Pied Piper}]
10[{title Prelude to War}]

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词左侧。

1[{title Where Are My Children?}]
2[{title The Four Horsemen of the Apocalypse}]
3[{title The Hunchback of Notre Dame}]
4[{title Show People}]
5[{title Berkeley Square}]
6[{title Folies Bergère de Paris}]
7[{title Here Comes Mr. Jordan}]
8[{title Cat People}]
9[{title People on the Alps}]
10[{title The Gang's All Here}]

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词右侧。

1[{title The Perils of Pauline}]
2[{title Les vampires}]
3[{title The Saphead}]
4[{title The Four Horsemen of the Apocalypse}]
5[{title He Who Gets Slapped}]
6[{title The Phantom of the Opera}]
7[{title Show People}]
8[{title The Blood of a Poet}]
9[{title The 3 Penny Opera}]
10[{title Shanghai Express}]

这些结果显示了针对字符串预测的单词,并在标题单词的不同位置修改了一个字符。

1{"title": "The Perils of Pauline"}
2{"title": "The Blood of a Poet"}
3{"title": "The Private Life of Henry VIII."}
4{"title": "The Private Life of Don Juan"}
5{"title": "The Prisoner of Shark Island"}
6{"title": "The Prince and the Pauper"}
7{"title": "The Prisoner of Zenda"}
8{"title": "Dance Program"}
9{"title": "The Pied Piper"}
10{'title': 'Prelude to War'}

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词左侧。

1{"title": "Where Are My Children?"}
2{"title": "The Four Horsemen of the Apocalypse"}
3{"title": "The Hunchback of Notre Dame"}
4{"title": "Show People"}
5{"title": "Berkeley Square"}
6{"title": "Folies Bergère de Paris"}
7{"title": "Here Comes Mr. Jordan"}
8{"title": "Cat People"}
9{"title": "People on the Alps"}
10{"title": "The Gang's All Here"}

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词右侧。

1{"title": "The Perils of Pauline"}
2{"title": "Les vampires"}
3{"title": "The Saphead"}
4{"title": "The Four Horsemen of the Apocalypse"}
5{"title": "He Who Gets Slapped"}
6{"title": "The Phantom of the Opera"}
7{"title": "Show People"}
8{"title": "The Blood of a Poet"}
9{"title": "The 3 Penny Opera"}
10{"title": "Shanghai Express"}

这些结果显示了针对字符串预测的单词,并在标题单词的不同位置修改了一个字符。

1Document{{title=The Perils of Pauline}}
2Document{{title=The Private Life of Henry VIII.}}
3Document{{title=Prelude to War}}
4Document{{title=Sitting Pretty}}
5Document{{title=The Prisoner}}
6Document{{title=Chi lavora è perduto (In capo al mondo)}}
7Document{{title=Profound Desires of the Gods}}
8Document{{title=The Protagonists}}
9Document{{title=Property Is No Longer a Theft}}
10Document{{title=Premiya}}

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词左侧。

1Document{{title=The Four Horsemen of the Apocalypse}}
2Document{{title=Folies Bergère de Paris}}
3Document{{title=Mother Wore Tights}}
4Document{{title=El hombre sin rostro}}
5Document{{title=Il segno di Venere}}
6Document{{title=Creature from the Black Lagoon}}
7Document{{title=Susan Slept Here}}
8Document{{title=Tell Them Willie Boy Is Here}}
9Document{{title=Pilatus und andere - Ein Film fèr Karfreitag}}
10Document{{title=Watch Out, We're Mad}}

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词右侧。

1Document{{title=The Four Horsemen of the Apocalypse}}
2Document{{title=The Private Life of Henry VIII.}}
3Document{{title=David Copperfield}}
4Document{{title=The Prisoner of Zenda}}
5Document{{title=People on the Alps}}
6Document{{title=Prelude to War}}
7Document{{title=The Pride of the Yankees}}
8Document{{title=Phantom of the Opera}}
9Document{{title=The Curse of the Cat People}}
10Document{{title=The People Against O'Hara}}

这些结果显示了针对字符串预测的单词,并在标题单词的不同位置修改了一个字符。

1{ title: 'The Perils of Pauline' }
2{ title: 'The Blood of a Poet' }
3{ title: 'The Private Life of Henry VIII.' }
4{ title: 'The Private Life of Don Juan' }
5{ title: 'The Prisoner of Shark Island' }
6{ title: 'The Prince and the Pauper' }
7{ title: 'The Prisoner of Zenda' }
8{ title: 'Dance Program' }
9{ title: 'The Pied Piper' }
10{ title: 'Prelude to War' }

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词左侧。

1{ title: 'Where Are My Children?' }
2{ title: 'The Four Horsemen of the Apocalypse' }
3{ title: 'The Hunchback of Notre Dame' }
4{ title: 'Show People' }
5{ title: 'Berkeley Square' }
6{ title: 'Folies Bergère de Paris' }
7{ title: 'Here Comes Mr. Jordan' }
8{ title: 'Cat People' }
9{ title: 'People on the Alps' }
10{ title: "The Gang's All Here" }

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词右侧。

1{ title: 'The Perils of Pauline' }
2{ title: 'Les vampires' }
3{ title: 'The Saphead' }
4{ title: 'The Four Horsemen of the Apocalypse' }
5{ title: 'He Who Gets Slapped' }
6{ title: 'The Phantom of the Opera' }
7{ title: 'Show People' }
8{ title: 'The Blood of a Poet' }
9{ title: 'The 3 Penny Opera' }
10{ title: 'Shanghai Express' }

这些结果显示了针对字符串预测的单词,并在标题单词的不同位置修改了一个字符。

1{'title': 'The Perils of Pauline'}
2{'title': 'The Blood of a Poet'}
3{'title': 'The Private Life of Henry VIII.'}
4{'title': 'The Private Life of Don Juan'}
5{'title': 'The Prisoner of Shark Island'}
6{'title': 'The Prince and the Pauper'}
7{'title': 'The Prisoner of Zenda'}
8{'title': 'Dance Program'}
9{'title': 'The Pied Piper'}
10{'title': 'Prelude to War'}

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词左侧。

1{'title': 'Where Are My Children?'}
2{'title': 'The Four Horsemen of the Apocalypse'}
3{'title': 'The Hunchback of Notre Dame'}
4{'title': 'Show People'}
5{'title': 'Berkeley Square'}
6{'title': 'Folies Bergère de Paris'}
7{'title': 'Here Comes Mr. Jordan'}
8{'title': 'Cat People'}
9{'title': 'People on the Alps'}
10{'title': "The Gang's All Here"}

这些结果显示修改一个字符后查询字符串中预测的单词,所有标题中第一个字符常量位于单词右侧。

1{'title': 'The Perils of Pauline'}
2{'title': 'Les vampires'}
3{'title': 'The Saphead'}
4{'title': 'The Four Horsemen of the Apocalypse'}
5{'title': 'He Who Gets Slapped'}
6{'title': 'The Phantom of the Opera'}
7{'title': 'Show People'}
8{'title': 'The Blood of a Poet'}
9{'title': 'The 3 Penny Opera'}
10{'title': 'Shanghai Express'}

这些结果显示了针对字符串预测的单词,并在标题单词的不同位置修改了一个字符。

以下查询演示如何在指定字段中搜索包含查询所指定字符序列的单词或短语。

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

1[
2 {
3 "$search": {
4 "index": "default",
5 "autocomplete": {
6 "path": "plot",
7 "query": "new purchase",
8 "tokenOrder": "any",
9 "fuzzy": {
10 "maxEdits": 2,
11 "prefixLength": 1,
12 "maxExpansions": 256
13 }
14 },
15 "highlight": {
16 "path": "plot"
17 }
18 }
19 }
20]
SCORE: 3 _id: "573a13a4f29313caabd112f0"
A divorced woman and her diabetic daughter take refuge in their newly-purchased house's safe room, when three men break-in, searching for a missing fortune.
Matching fields: plot
SCORE: 3 _id: "573a13d1f29313caabd8e209"
A lonely writer develops an unlikely relationship with his newly purchased operating system that's designed to meet his every need.
Matching fields: plot
SCORE: 2 _id: "573a13bef29313caabd5b62d"
Set in the near future when artificial organs can be bought on credit, it revolves around a man who struggles to make the payments on a heart he has purchased. He must
Matching fields: plot
SCORE: 2 _id: "573a13b3f29313caabd3c91e"
He is "purchased" by a wealthy television producer and taken to a desolate island where he must fight to the death against nine other condemned killers from all corners of the world, with freedom going to the sole survivor.
Matching fields: plot
SCORE: 2 _id: "573a1398f29313caabceb931"
A country boy becomes the head of a gang through the purchase of some lucky roses from an old lady.
Matching fields: plot, plot
SCORE: 1 _id: "573a13a7f29313caabd1b5ab"
An illegal Nigerian immigrant discovers the unpalatable side of London life.
Matching fields: plot
SCORE: 1 _id: "573a13a7f29313caabd1b5c0"
A young dropout falls in love with a nightclub dancer...
Matching fields: plot
SCORE: 1 _id: "573a13a7f29313caabd1b62f"
In 1990, to protect his fragile mother from a fatal shock after a long coma, a young man must keep her from learning that her beloved nation of East Germany as she knew it has disappeared.
Matching fields: plot
SCORE: 1 _id: "573a13a7f29313caabd1b6af"
Gadget once again has to fight his arch nemesis, Claw.
Matching fields: plot

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

1db.movies.aggregate([
2 {
3 "$search": {
4 "index": "default",
5 "autocomplete": {
6 "path": "plot",
7 "query": "new purchase",
8 "tokenOrder": "any",
9 "fuzzy": {
10 "maxEdits": 2,
11 "prefixLength": 1,
12 "maxExpansions": 256
13 }
14 },
15 "highlight": {
16 "path": "plot"
17 }
18 }
19 },
20 {
21 "$limit": 5
22 },
23 {
24 "$project": {
25 "_id": 0,
26 "title": 1,
27 "plot": 1,
28 "highlights": { "$meta": "searchHighlights" }
29 }
30 }
31])
[
{
plot: "A divorced woman and her diabetic daughter take refuge in their newly-purchased house's safe room, when three men break-in, searching for a missing fortune.",
title: 'Panic Room',
highlights: [
{
score: 4.364492893218994,
path: 'plot',
texts: [
{
value: 'A divorced woman and her diabetic daughter take refuge in their ',
type: 'text'
},
{ value: "newly-purchased house's safe", type: 'hit' },
{
value: ' room, when three men break-in, searching for a missing fortune.',
type: 'text'
}
]
}
]
},
{
plot: "A lonely writer develops an unlikely relationship with his newly purchased operating system that's designed to meet his every need.",
title: 'Her',
highlights: [
{
score: 4.198050022125244,
path: 'plot',
texts: [
{
value: 'A lonely writer develops an unlikely relationship with his ',
type: 'text'
},
{ value: 'newly purchased operating system', type: 'hit' },
{
value: " that's designed to meet his every ",
type: 'text'
},
{ value: 'need', type: 'hit' },
{ value: '.', type: 'text' }
]
}
]
},
{
plot: "Set in the near future when artificial organs can be bought on credit, it revolves around a man who struggles to make the payments on a heart he has purchased. He must therefore go on the run before said ticker is repossessed.",
title: 'Repo Men',
highlights: [
{
score: 2.6448397636413574,
path: 'plot',
texts: [
{ value: 'Set in the ', type: 'text' },
{ value: 'near future when', type: 'hit' },
{ value: ' artificial organs can be bought on credit, it revolves around a man who struggles to make the payments on a heart he has ', type: 'text' },
{ value: 'purchased. He must', type: 'hit' }
]
}
]
},
{
plot: 'A psychologically troubled novelty supplier is nudged towards a romance with an English woman, all the while being extorted by a phone-sex line run by a crooked mattress salesman, and purchasing stunning amounts of pudding.',
title: 'Punch-Drunk Love',
highlights: [
{
score: 1.2451990842819214,
path: 'plot',
texts: [
{ value: 'A psychologically troubled ', type: 'text' },
{ value: 'novelty supplier is', type: 'hit' },
{ value: ' ', type: 'text' },
{ value: 'nudged towards a', type: 'hit' },
{
value: ' romance with an English woman, all the while being extorted by a phone-sex line run by a crooked mattress salesman, and ',
type: 'text'
},
{ value: 'purchasing stunning amounts', type: 'hit' },
{ value: ' of pudding.', type: 'text' }
]
}
]
},
{
plot: 'Jack Conrad is awaiting the death penalty in a corrupt Central American prison. He is "purchased" by a wealthy television producer and taken to a desolate island where he must fight to the death against nine other condemned killers from all corners of the world, with freedom going to the sole survivor.',
title: 'The Condemned',
highlights: [
{
score: 2.94378924369812,
path: 'plot',
texts: [
{ value: 'He is "', type: 'text' },
{ value: 'purchased" by a', type: 'hit' },
{
value: ' wealthy television producer and taken to a desolate island where he must fight to the death against ',
type: 'text'
},
{ value: 'nine other condemned', type: 'hit' },
{
value: ' killers from all corners of the world, with freedom going to the sole survivor.',
type: 'text'
}
]
}
]
}
]

以下查询使用该操作符查询 sample_mflix.movies 集合的 plot 字段。该查询包括:

  • $limit 阶段用于将输出限制为 5 个结果

  • $project 阶段排除 titleplot 以外的所有字段。

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

管道阶段
查询

$search

{
"index": "default",
"autocomplete": {
"path": "plot",
"query": "new purchase",
"tokenOrder": "any",
"fuzzy": {
"maxEdits": 2,
"prefixLength": 1,
"maxExpansions": 256
}
},
"highlight": {
"path": "plot"
}
}

$limit

5

$project

{
"_id": 0,
"title": 1,
"plot": 1,
"highlights": { "$meta": "searchHighlights" }
}

如果启用了 Auto Preview,MongoDB Compass 将在 $project 管道阶段旁边显示以下文档:

1[
2 {
3 plot: "A divorced woman and her diabetic daughter take refuge in their newly-purchased house's safe room, when three men break-in, searching for a missing fortune.",
4 title: 'Panic Room',
5 highlights: [
6 {
7 score: 4.364492893218994,
8 path: 'plot',
9 texts: [
10 {
11 value: 'A divorced woman and her diabetic daughter take refuge in their ',
12 type: 'text'
13 },
14 { value: "newly-purchased house's safe", type: 'hit' },
15 {
16 value: ' room, when three men break-in, searching for a missing fortune.',
17 type: 'text'
18 }
19 ]
20 }
21 ]
22 },
23 {
24 plot: "A lonely writer develops an unlikely relationship with his newly purchased operating system that's designed to meet his every need.",
25 title: 'Her',
26 highlights: [
27 {
28 score: 4.198050022125244,
29 path: 'plot',
30 texts: [
31 {
32 value: 'A lonely writer develops an unlikely relationship with his ',
33 type: 'text'
34 },
35 { value: 'newly purchased operating system', type: 'hit' },
36 {
37 value: " that's designed to meet his every ",
38 type: 'text'
39 },
40 { value: 'need', type: 'hit' },
41 { value: '.', type: 'text' }
42 ]
43 }
44 ]
45 },
46 {
47 plot: "Set in the near future when artificial organs can be bought on credit, it revolves around a man who struggles to make the payments on a heart he has purchased. He must therefore go on the run before said ticker is repossessed.",
48 title: 'Repo Men',
49 highlights: [
50 {
51 score: 2.6448397636413574,
52 path: 'plot',
53 texts: [
54 { value: 'Set in the ', type: 'text' },
55 { value: 'near future when', type: 'hit' },
56 { value: ' artificial organs can be bought on credit, it revolves around a man who struggles to make the payments on a heart he has ', type: 'text' },
57 { value: 'purchased. He must', type: 'hit' }
58 ]
59 }
60 ]
61 },
62 {
63 plot: 'A psychologically troubled novelty supplier is nudged towards a romance with an English woman, all the while being extorted by a phone-sex line run by a crooked mattress salesman, and purchasing stunning amounts of pudding.',
64 title: 'Punch-Drunk Love',
65 highlights: [
66 {
67 score: 1.2451990842819214,
68 path: 'plot',
69 texts: [
70 { value: 'A psychologically troubled ', type: 'text' },
71 { value: 'novelty supplier is', type: 'hit' },
72 { value: ' ', type: 'text' },
73 { value: 'nudged towards a', type: 'hit' },
74 {
75 value: ' romance with an English woman, all the while being extorted by a phone-sex line run by a crooked mattress salesman, and ',
76 type: 'text'
77 },
78 { value: 'purchasing stunning amounts', type: 'hit' },
79 { value: ' of pudding.', type: 'text' }
80 ]
81 }
82 ]
83 },
84 {
85 plot: 'Jack Conrad is awaiting the death penalty in a corrupt Central American prison. He is "purchased" by a wealthy television producer and taken to a desolate island where he must fight to the death against nine other condemned killers from all corners of the world, with freedom going to the sole survivor.',
86 title: 'The Condemned',
87 highlights: [
88 {
89 score: 2.94378924369812,
90 path: 'plot',
91 texts: [
92 { value: 'He is "', type: 'text' },
93 { value: 'purchased" by a', type: 'hit' },
94 {
95 value: ' wealthy television producer and taken to a desolate island where he must fight to the death against ',
96 type: 'text'
97 },
98 { value: 'nine other condemned', type: 'hit' },
99 {
100 value: ' killers from all corners of the world, with freedom going to the sole survivor.',
101 type: 'text'
102 }
103 ]
104 }
105 ]
106 }
107]

此代码示例将执行以下任务:

  • 导入mongodb包和依赖项。

  • 建立与您的 Atlas 集群的连接。

  • 运行使用以下项的查询:

    • $search 寻找术语的阶段

    • $limit 阶段用于将输出限制为 5 个结果

    • $project 阶段,用于排除除以下字段之外的所有字段 title
      plot
  • 遍历游标以打印与查询匹配的文档。

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

1using MongoDB.Bson;
2using MongoDB.Bson.Serialization.Attributes;
3using MongoDB.Bson.Serialization.Conventions;
4using MongoDB.Driver;
5using MongoDB.Driver.Search;
6
7public class PartialAutocomplete
8{
9 private const string MongoConnectionString = "<connection-string>";
10
11 public static void Main(string[] args) {
12 // allow automapping of the camelCase database fields to our MovieDocument
13 var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
14 ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
15
16 // connect to your Atlas cluster
17 var mongoClient = new MongoClient(MongoConnectionString);
18 var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
19 var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
20
21 // define fuzzy options
22 SearchFuzzyOptions fuzzyOptions = new SearchFuzzyOptions()
23 {
24 MaxEdits = 2,
25 PrefixLength = 1,
26 MaxExpansions = 256
27 };
28
29 // define and run pipeline
30 var results = moviesCollection.Aggregate()
31 .Search(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Plot, "new purchase", SearchAutocompleteTokenOrder.Any, fuzzy: fuzzyOptions), new SearchHighlightOptions<MovieDocument>(movie => movie.Plot),
32 indexName: "default")
33 .Project<MovieDocument>(Builders<MovieDocument>.Projection
34 .Include(movie => movie.Plot)
35 .Include(movie => movie.Title)
36 .Exclude(movie => movie.Id)
37 .MetaSearchHighlights("highlights"))
38 .Limit(5)
39 .ToList();
40
41 // print results
42 foreach (var movie in results) {
43 Console.WriteLine(movie.ToJson());
44 }
45 }
46}
47
48[BsonIgnoreExtraElements]
49public class MovieDocument {
50 [BsonIgnoreIfDefault]
51 public ObjectId Id { get; set; }
52 public string Plot { get; set; }
53 public string Title { get; set; }
54 [BsonElement("highlights")]
55 public List<SearchHighlight> Highlights { get; set; }
56}

以下查询使用该操作符查询 sample_mflix.movies 集合的 plot 字段。该查询包括:

  • $limit 阶段用于将输出限制为 5 个结果

  • $project 阶段排除 titleplot 以外的所有字段。

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

1package main
2
3import (
4 "context"
5 "fmt"
6 "time"
7
8 "go.mongodb.org/mongo-driver/v2/bson"
9 "go.mongodb.org/mongo-driver/v2/mongo"
10 "go.mongodb.org/mongo-driver/v2/mongo/options"
11)
12
13// define structure of movies collection
14type Movie struct {
15 title string
16 plot string
17}
18
19func main() {
20 var err error
21 // connect to the Atlas cluster
22 ctx := context.Background()
23 client, err := mongo.Connect(options.Client().SetTimeout(5 * time.Second).ApplyURI("<connection-string>"))
24 if err != nil {
25 panic(err)
26 }
27 defer client.Disconnect(ctx)
28 // set namespace
29 collection := client.Database("sample_mflix").Collection("movies")
30 // define pipeline
31 searchStage := bson.D{{Key: "$search", Value: bson.M{
32 "index": "default",
33 "autocomplete": bson.M{
34 "path": "plot", "query": "new purchase", "tokenOrder": "any", "fuzzy": bson.M{
35 "maxEdits": 2, "prefixLength": 1, "maxExpansions": 256},
36 },
37 "highlight": bson.D{
38 {Key: "path", Value: "plot"},
39 },
40 }}}
41 limitStage := bson.D{{Key: "$limit", Value: 5}}
42 projectStage := bson.D{{Key: "$project", Value: bson.D{{Key: "title", Value: 1}, {Key: "plot", Value: 1}, {Key: "_id", Value: 0}, {Key: "highlights", Value: bson.D{{Key: "$meta", Value: "searchHighlights"}}}}}}
43 // run pipeline
44 cursor, err := collection.Aggregate(ctx, mongo.Pipeline{searchStage, limitStage, projectStage})
45 if err != nil {
46 panic(err)
47 }
48 // print results
49 var results []Movie
50 if err = cursor.All(context.TODO(), &results); err != nil {
51 panic(err)
52 }
53 for _, result := range results {
54 fmt.Println(result)
55 }
56}

此代码示例将执行以下任务:

  • 导入mongodb包和依赖项。

  • 建立与您的 Atlas 集群的连接。

  • 运行使用以下项的查询:

    • $search 寻找术语的阶段

    • $limit 阶段用于将输出限制为 5 个结果

    • $project 阶段排除 titleplot 以外的所有字段。

  • 遍历游标以打印与查询匹配的文档。

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

1import java.util.Arrays;
2import static com.mongodb.client.model.Aggregates.limit;
3import static com.mongodb.client.model.Aggregates.project;
4import static com.mongodb.client.model.Projections.excludeId;
5import static com.mongodb.client.model.Projections.fields;
6import static com.mongodb.client.model.Projections.include;
7import com.mongodb.client.MongoClient;
8import com.mongodb.client.MongoClients;
9import com.mongodb.client.MongoCollection;
10import com.mongodb.client.MongoDatabase;
11import org.bson.Document;
12
13public class PartialMatchQuery {
14 public static void main( String[] args ) {
15
16 // define query
17 Document agg = new Document("$search",
18 new Document ("index", "default")
19 .append("autocomplete",
20 new Document("path", "plot")
21 .append("query", "new purchase")
22 .append("tokenOrder", "any")
23 .append("fuzzy",
24 new Document("maxEdits", 2)
25 .append("prefixLength", 1)
26 .append("maxExpansions", 256))));
27
28 // specify connection
29 String uri = "<connection-string>";
30
31 // establish connection and set namespace
32 try (MongoClient mongoClient = MongoClients.create(uri)) {
33 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
34 MongoCollection<Document> collection = database.getCollection("movies");
35 // run query and print results
36 collection.aggregate(Arrays.asList(agg,
37 limit(5),
38 project(fields(excludeId(), include("title", "plot")))))
39 .forEach(doc -> System.out.println(doc.toJson()));
40 }
41 }
42}

此代码示例将执行以下任务:

  • 导入mongodb包和依赖项。

  • 建立与您的 Atlas 集群的连接。

  • 运行使用以下项的查询:

    • $search 寻找术语的阶段

    • $limit 阶段用于将输出限制为 5 个结果

    • $project 阶段排除 titleplot 以外的所有字段。

  • 打印与 AggregateFlow 实例中的查询相匹配的文档。

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

1import com.mongodb.client.model.Aggregates.limit
2import com.mongodb.client.model.Aggregates.project
3import com.mongodb.client.model.Projections.*
4import com.mongodb.kotlin.client.coroutine.MongoClient
5import kotlinx.coroutines.runBlocking
6import org.bson.Document
7
8fun main() {
9 // establish connection and set namespace
10 val uri = "<connection-string>"
11 val mongoClient = MongoClient.create(uri)
12 val database = mongoClient.getDatabase("sample_mflix")
13 val collection = database.getCollection<Document>("movies")
14
15 runBlocking {
16 // define query
17 val agg = Document(
18 "\$search",
19 Document("index", "default")
20 .append(
21 "autocomplete",
22 Document("path", "plot")
23 .append("query", "new purchase")
24 .append("tokenOrder", "any")
25 .append(
26 "fuzzy",
27 Document("maxEdits", 2)
28 .append("prefixLength", 1)
29 .append("maxExpansions", 256)
30 )
31 )
32 )
33
34 // run query and print results
35 val resultsFlow = collection.aggregate<Document>(
36 listOf(
37 agg,
38 limit(5),
39 project(fields(excludeId(), include("title", "plot")))
40 )
41 )
42 resultsFlow.collect { println(it) }
43 }
44 mongoClient.close()
45}

此代码示例将执行以下任务:

  • 导入 mongodb,即 MongoDB 的 Node.js 驱动程序。

  • 创建一个 MongoClient 类实例,以建立与 Atlas 集群的连接。

  • 运行使用以下项的查询:

    • $search 寻找术语的阶段

    • $limit 阶段用于将输出限制为 5 个结果

    • $project 阶段排除 titleplot 以外的所有字段。

  • 遍历游标以打印与查询匹配的文档。

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

1const MongoClient = require("mongodb").MongoClient;
2const assert = require("assert");
3
4const agg = [
5 {
6 '$search': {
7 'index': 'default',
8 'autocomplete': {
9 'path': 'plot',
10 'query': 'new purchase',
11 'tokenOrder': 'any',
12 'fuzzy': {
13 'maxEdits': 2,
14 'prefixLength': 1,
15 'maxExpansions': 256
16 }
17 },
18 'highlight': {
19 'path': 'plot'
20 }
21 }
22 }, {
23 '$limit': 5
24 }, {
25 '$project': {
26 '_id': 0,
27 'title': 1,
28 'plot': 1,
29 'highlights': {
30 '$meta': 'searchHighlights'
31 }
32 }
33 }
34];
35
36MongoClient.connect(
37 "<connection-string>",
38 { useNewUrlParser: true, useUnifiedTopology: true },
39 async function (connectErr, client) {
40 assert.equal(null, connectErr);
41 const coll = client.db("sample_mflix").collection("movies");
42 let cursor = await coll.aggregate(agg);
43 await cursor.forEach((doc) => console.log(doc));
44 client.close();
45 }
46);

以下代码示例:

  • 导入 pymongo 、MongoDB 的 Python 驱动程序和 dns 模块,这是使用 DNS 种子列表连接字符串将 pymongo 连接到 Atlas 所必需的。

  • 创建一个 MongoClient 类实例,以建立与 Atlas 集群的连接。

  • 运行使用以下项的查询:

    • $search 寻找术语的阶段

    • $limit 阶段用于将输出限制为 5 个结果

    • $project 阶段排除 titleplot 以外的所有字段。

  • 遍历游标以打印与查询匹配的文档。

该查询允许执行以下操作,以将查询字符串 new purchase 与字段中的单词进行匹配:

  • 允许单词 newpurchase 出现在 plot 字段的任何位置。

  • 允许查询字符串中的两个字符变体将查询与字段中的单词匹配,但不允许更改查询字符串中的第一个字符。

  • 最多允许考虑 256 个相似词。

1import pymongo
2import dns
3
4client = pymongo.MongoClient('<connection-string>')
5result = client['sample_mflix']['movies'].aggregate([
6 {
7 '$search': {
8 'index': 'default',
9 'autocomplete': {
10 'path': 'plot',
11 'query': 'new purchase',
12 'tokenOrder': 'any',
13 'fuzzy': {
14 'maxEdits': 2,
15 'prefixLength': 1,
16 'maxExpansions': 256
17 }
18 },
19 'highlight': {
20 'path': 'plot'
21 }
22 }
23 }, {
24 '$limit': 5
25 }, {
26 '$project': {
27 '_id': 0,
28 'title': 1,
29 'plot': 1,
30 'highlights': {
31 '$meta': 'searchHighlights'
32 }
33 }
34 }
35])
36
37for i in result:
38 print(i)

以下查询搜索在 title 字段中包含字符 men with 的电影。这些查询还使用 tokenOrder 字段,该字段指定查询是按 any 顺序还是按 sequential 顺序搜索令牌。

您可以使用关键字分析器title 字段编入索引,搜索以某个术语或短语开头的电影片名。

您必须使用带有 edgeGram 分词策略的关键字分析器为该字段编制索引,才能检索以下示例查询的结果。如果您使用任何其他内置分析器对该字段建立索引,Atlas Search 不会返回任何结果,因为它不会将您的文本字段作为单个字词来建立索引。edgeGram 分词策略创建从单词左侧开始的分词。

您还必须将 foldDiacritics 设置为 true 才能返回不区分大小写的结果。如果将 foldDiacritics 设置为 false,则查询字词的大小写必须与文档中的字词大小写完全匹配,Atlas Search 才能返回结果(如有)。

{
"mappings": {
"dynamic": false,
"fields": {
"title": [
{
"type": "stringFacet"
},
{
"type": "string"
},
{
"foldDiacritics": true,
"maxGrams": 7,
"minGrams": 3,
"analyzer": "lucene.keyword",
"tokenization": "edgeGram",
"type": "autocomplete"
}]
}
}
}

以下查询搜索以 Fast & 开头的电影标题。

将以下查询复制并粘贴到 Query Editor 中,然后点击 Query Editor 中的 Search 按钮。

[
{
$search: {
autocomplete: {
path: "title",
query: "Fast &",
tokenOrder: "sequential"
}
}
}
]

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

db.movies.aggregate([
{
$search: {
"autocomplete": {
"query": "Fast &",
"path": "title",
"tokenOrder": "sequential"
}
}
},
{
$project: {
"_id": 0,
"title": 1
}
},
{
$limit: 4
}
])

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

movies 集合的 Aggregations 标签页中,从下拉菜单中选择阶段并为该阶段添加查询,以配置以下每个管道阶段。单击 Add Stage 添加其他阶段。

管道阶段
查询

$search

{
"autocomplete": {
"query": "Fast &",
"path": "title",
"tokenOrder": "sequential"
}
}

$limit

4

$project

{
"_id": 0,
"title": 1,
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;
using MongoDB.Driver.Search;
public class AutocompleteTokenOrderSequentialStartsWithExample
{
private const string MongoConnectionString = "<connection-string>";
public static void Main(string[] args)
{
// allow automapping of the camelCase database fields to our MovieDocument
var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
// connect to your Atlas cluster
var mongoClient = new MongoClient(MongoConnectionString);
var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
// define and run pipeline
var results = moviesCollection.Aggregate()
.Search(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Title, "Fast &", SearchAutocompleteTokenOrder.Sequential))
.Project<MovieDocument>(Builders<MovieDocument>.Projection
.Include(movie => movie.Title)
.Exclude(movie => movie.Id))
.Limit(4)
.ToList();
// print results
foreach (var movie in results)
{
Console.WriteLine(movie.ToJson());
}
}
}
[BsonIgnoreExtraElements]
public class MovieDocument
{
[BsonIgnoreIfDefault]
public ObjectId Id { get; set; }
public string Title { get; set; }
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

package main
import (
"context"
"fmt"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func main() {
// connect to your Atlas cluster
client, err := mongo.Connect(options.Client().ApplyURI("<connection-string>"))
if err != nil {
panic(err)
}
defer client.Disconnect(context.TODO())
// set namespace
collection := client.Database("sample_mflix").Collection("movies")
// define pipeline stages
searchStage := bson.D{{Key: "$search", Value: bson.D{{Key: "autocomplete", Value: bson.D{{Key: "query", Value: "Fast &"}, {Key: "path", Value: "title"}, {Key: "tokenOrder", Value: "sequential"}}}}}}
limitStage := bson.D{{Key: "$limit", Value: 4}}
projectStage := bson.D{{Key: "$project", Value: bson.D{{Key: "title", Value: 1}, {Key: "_id", Value: 0}}}}
// run pipeline
cursor, err := collection.Aggregate(context.TODO(), mongo.Pipeline{searchStage, limitStage, projectStage})
if err != nil {
panic(err)
}
// print results
var results []bson.D
if err = cursor.All(context.TODO(), &results); err != nil {
panic(err)
}
for _, result := range results {
fmt.Println(result)
}
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import static com.mongodb.client.model.Aggregates.limit;
import static com.mongodb.client.model.Aggregates.project;
import static com.mongodb.client.model.Projections.excludeId;
import static com.mongodb.client.model.Projections.fields;
import static com.mongodb.client.model.Projections.include;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import java.util.Arrays;
public class AutocompleteStartsWith {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("sample_mflix");
MongoCollection<Document> collection = database.getCollection("movies");
// define pipeline
Document agg = new Document("$search", new Document("autocomplete", new Document("query", "Fast &").append("path", "title").append("tokenOrder", "sequential")));
// run pipeline and print results
collection.aggregate(Arrays.asList(agg,
limit(4),
project(fields(excludeId(), include("title"))))).forEach(doc -> System.out.println(doc.toJson()));
}
}
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import com.mongodb.client.model.Aggregates.limit
import com.mongodb.client.model.Aggregates.project
import com.mongodb.client.model.Projections.*
import com.mongodb.kotlin.client.coroutine.MongoClient
import kotlinx.coroutines.runBlocking
import org.bson.Document
fun main() {
val uri = "<connection-string>"
val mongoClient = MongoClient.create(uri)
val database = mongoClient.getDatabase("sample_mflix")
val collection = database.getCollection<Document>("movies")
runBlocking {
val agg = Document(
"\$search",
Document(
"autocomplete",
Document("query", "Fast &")
.append("path", "title")
.append("tokenOrder", "sequential")
)
)
val resultsFlow = collection.aggregate<Document>(
listOf(
agg,
limit(4),
project(fields(excludeId(), include("title")))
)
)
resultsFlow.collect { println(it) }
}
mongoClient.close()
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

const { MongoClient } = require("mongodb");
// connect to your Atlas cluster
const uri =
"<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
await client.connect();
// set namespace
const database = client.db("sample_mflix");
const coll = database.collection("movies");
// define pipeline
const agg = [
{$search: {autocomplete: {query: "Fast &", path: "title", tokenOrder: "sequential"}}},
{$limit: 4},
{$project: {_id: 0,title: 1}}
];
// run pipeline
const result = await coll.aggregate(agg);
// print results
await result.forEach((doc) => console.log(doc));
} finally {
await client.close();
}
}
run().catch(console.dir);

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import pymongo
# connect to your Atlas cluster
client = pymongo.MongoClient('<connection-string>')
# define pipeline
pipeline = [
{"$search": {"autocomplete": {"query": "men with", "path": "title", "tokenOrder": "sequential"}}},
{"$limit": 4},
{"$project": {"_id": 0, "title": 1}},
]
# run pipeline
result = client["sample_mflix"]["movies"].aggregate(pipeline)
# print results
for i in result:
print(i)
SCORE: 10.042893409729004 _id: “573a13bdf29313caabd5929f”
fullplot: "Heading back to the streets where it all began, two men rejoin two wom…"
imdb: Object
year: 2009
...
title: "Fast & Furious"
SCORE: 9.515419006347656 _id: “573a13d3f29313caabd95cc5”
fullplot: "Since Dom (Diesel) and Brian's (Walker) Rio heist toppled a kingpin's …"
imdb: Object
year: 2013
...
title "Fast & Furious 6"

Search Tester 可能不会显示其所返回文档的所有字段。要查看所有字段,包括在查询路径中指定的字段,请展开结果中的文档。

1{ title: 'Fast & Furious' },
2{ title: 'Fast & Furious 6' }
1{ title: 'Fast & Furious' },
2{ title: 'Fast & Furious 6' }
1{ "title" : "Fast & Furious" }
2{ "title" : "Fast & Furious 6" }
1 [{title Fast & Furious}]
2 [{title Fast & Furious 6}]
1{"title": "Fast & Furious"}
2{"title": "Fast & Furious 6"}
1Document{{title=Fast & Furious}}
2Document{{title=Fast & Furious 6}}
1{ title: 'Fast & Furious' }
2{ title: 'Fast & Furious 6' }
1{'title': 'Fast & Furious'}
2{'title': 'Fast & Furious 6'}

将以下查询复制并粘贴到 Query Editor 中,然后点击 Query Editor 中的 Search 按钮。

[
{
$search: {
autocomplete: {
path: "title",
query: "men with",
tokenOrder: "any"
}
}
}
]

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

db.movies.aggregate([
{
$search: {
"autocomplete": {
"path": "title",
"query": "men with",
"tokenOrder": "any"
}
}
},
{
$limit: 4
},
{
$project: {
"_id": 0,
"title": 1
}
}
])

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

movies 集合的 Aggregations 标签页中,从下拉菜单中选择阶段并为该阶段添加查询,以配置以下每个管道阶段。单击 Add Stage 添加其他阶段。

管道阶段
查询

$search

{
"autocomplete": {
"query": "men with",
"path": "title",
"tokenOrder": "any"
}
}

$limit

4

$project

{
"_id": 0,
"title": 1,
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;
using MongoDB.Driver.Search;
public class AutocompleteTokenOrderAnyExample
{
private const string MongoConnectionString = "<connection-string>";
public static void Main(string[] args)
{
// allow automapping of the camelCase database fields to our MovieDocument
var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
// connect to your Atlas cluster
var mongoClient = new MongoClient(MongoConnectionString);
var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
// define and run pipeline
var results = moviesCollection.Aggregate()
.Search(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Title, "men with", SearchAutocompleteTokenOrder.Any))
.Project<MovieDocument>(Builders<MovieDocument>.Projection
.Include(movie => movie.Title)
.Exclude(movie => movie.Id))
.Limit(4)
.ToList();
// print results
foreach (var movie in results)
{
Console.WriteLine(movie.ToJson());
}
}
}
[BsonIgnoreExtraElements]
public class MovieDocument
{
[BsonIgnoreIfDefault]
public ObjectId Id { get; set; }
public string Title { get; set; }
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

package main
import (
"context"
"fmt"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func main() {
// connect to your Atlas cluster
client, err := mongo.Connect(options.Client().ApplyURI("<connection-string>"))
if err != nil {
panic(err)
}
defer client.Disconnect(context.TODO())
// set namespace
collection := client.Database("sample_mflix").Collection("movies")
// define pipeline stages
searchStage := bson.D{{Key: "$search", Value: bson.D{{Key: "autocomplete", Value: bson.D{{Key: "query", Value: "men with"}, {Key: "path", Value: "title"}, {Key: "tokenOrder", Value: "any"}}}}}}
limitStage := bson.D{{Key: "$limit", Value: 4}}
projectStage := bson.D{{Key: "$project", Value: bson.D{{Key: "title", Value: 1}, {Key: "_id", Value: 0}}}}
// run pipeline
cursor, err := collection.Aggregate(context.TODO(), mongo.Pipeline{searchStage, limitStage, projectStage})
if err != nil {
panic(err)
}
// print results
var results []bson.D
if err = cursor.All(context.TODO(), &results); err != nil {
panic(err)
}
for _, result := range results {
fmt.Println(result)
}
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import static com.mongodb.client.model.Aggregates.limit;
import static com.mongodb.client.model.Aggregates.project;
import static com.mongodb.client.model.Projections.excludeId;
import static com.mongodb.client.model.Projections.fields;
import static com.mongodb.client.model.Projections.include;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import java.util.Arrays;
public class AutocompleteTokenAny {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("sample_mflix");
MongoCollection<Document> collection = database.getCollection("movies");
// define pipeline
Document agg = new Document("$search", new Document("autocomplete", new Document("query", "men with").append("path", "title").append("tokenOrder", "any")));
// run pipeline and print results
collection.aggregate(Arrays.asList(agg,
limit(4),
project(fields(excludeId(), include("title"))))).forEach(doc -> System.out.println(doc.toJson()));
}
}
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import com.mongodb.client.model.Aggregates.limit
import com.mongodb.client.model.Aggregates.project
import com.mongodb.client.model.Projections.*
import com.mongodb.kotlin.client.coroutine.MongoClient
import kotlinx.coroutines.runBlocking
import org.bson.Document
fun main() {
val uri = "<connection-string>"
val mongoClient = MongoClient.create(uri)
val database = mongoClient.getDatabase("sample_mflix")
val collection = database.getCollection<Document>("movies")
runBlocking {
val agg = Document(
"\$search",
Document("autocomplete", Document("query", "men with")
.append("path", "title")
.append("tokenOrder", "any"))
)
val resultsFlow = collection.aggregate<Document>(
listOf(
agg,
limit(4),
project(fields(excludeId(), include("title")))
)
)
resultsFlow.collect { println(it) }
}
mongoClient.close()
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

const { MongoClient } = require("mongodb");
// connect to your Atlas cluster
const uri =
"<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
await client.connect();
// set namespace
const database = client.db("sample_mflix");
const coll = database.collection("movies");
// define pipeline
const agg = [
{$search: {autocomplete: {query: "men with", path: "title", tokenOrder: "any"}}},
{$limit: 4},
{$project: {_id: 0,title: 1}}
];
// run pipeline
const result = await coll.aggregate(agg);
// print results
await result.forEach((doc) => console.log(doc));
} finally {
await client.close();
}
}
run().catch(console.dir);

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import pymongo
# connect to your Atlas cluster
client = pymongo.MongoClient('<connection-string>')
# define pipeline
pipeline = [
{"$search": {"autocomplete": {"query": "men with", "path": "title", "tokenOrder": "any"}}},
{"$limit": 4},
{"$project": {"_id": 0, "title": 1}},
]
# run pipeline
result = client["sample_mflix"]["movies"].aggregate(pipeline)
# print results
for i in result:
print(i)

注意

结果可能会有所不同

Atlas Search 根据自动完成类型的索引定义中配置的分词策略返回不同的结果。要了解更多信息,请参阅如何为自动完成的字段编制索引。

SCORE: 21.18158721923828 _id: “573a139af29313caabcf0b12”
plot: "Humberto Fuentes is a wealthy doctor whose wife has recently died. In …"
genres: Array
runtime: 127
...
title: "Men with Guns"
SCORE: 21.18158721923828 _id: “573a13a4f29313caabd1287f”
plot: "Paul Gross stars as the leader of a recently reunited curling team fro…"
genres: Array
runtime: 102
...
title: "Men with Brooms"
SCORE: 19.015962600708008 _id: “573a1391f29313caabcd93a3”
plot: "Navy divers clear the torpedo tube of a sunken submarine."
genres: Array
runtime: 77
...
title: "Men Without Women"
SCORE: 11.215812683105469 _id: “573a13b8f29313caabd4bcbf”
plot: "A graduate student (Nicholson) copes with a recent breakup by conducti…"
genres: Array
runtime: 80
...
title: "Brief Interviews with Hideous Men"
SCORE: 10.668076515197754 _id: “573a13c9f29313caabd7ba99”
plot: "The women of a remote Latin American town are forced to pick up the pi…""
genres: Array
runtime: 87
...
title: "Without Men"
SCORE: 10.106664657592773 _id: “573a13c8f29313caabd77ab6”
plot: "Against the tumultuous backdrop of Iran's 1953 CIA-backed coup d'ètat,…"
genres: Array
runtime: 95
...
title: "Women Without Men"
SCORE: 7.458737373352051 _id: “573a1398f29313caabce9a19”
plot: "A man's wife leaves him to take up with an artist, so the man responds…"
genres: Array
runtime: 99
...
title: "Men..."
SCORE: 7.405402183532715 _id: “573a13f2f29313caabdde0b4”
plot: "Men and Chicken is a black comedy about two outcast brothers, who by g…"
genres: Array
runtime: 104
...
title: "Men & Chicken"
SCORE: 7.2005205154418945 _id: “573a1394f29313caabce06c3”
plot: "During the Korean War, a battle worn Lt. and his platoon behind enemy …"
genres: Array
runtime: 102
...
title: "Men in War"
SCORE: 7.2005205154418945 _id: “573a1399f29313caabcec167”
plot: "A mother of two sons finds life considerably difficult on her own afte…"
genres: Array
runtime: 115
...
title: "Men Don't Leave"
SCORE: 19.302995681762695 _id: “573a139af29313caabcf0b12”
plot: "Humberto Fuentes is a wealthy doctor whose wife has recently died. In …"
genres: Array
runtime: 127
...
title: "Men with Guns"
SCORE: 19.302995681762695 _id: “573a13a4f29313caabd1287f”
plot: "Paul Gross stars as the leader of a recently reunited curling team fro…"
genres: Array
runtime: 102
...
title: "Men with Brooms"
SCORE: 13.835155487060547 _id: “573a1399f29313caabcee64e”
plot: "A thief's son cons his father into spending more time with him."
genres: Array
runtime: 109
...
title: "Getting Even with Dad"
SCORE: 13.309324264526367 _id: “573a13cdf29313caabd844f5”
plot: "Since his beloved violin was broken, Nasser Ali Khan, one of the most …"
genres: Array
runtime: 93
...
title: "Chicken with Plums"
SCORE: 12.078420639038086 _id: “573a13b8f29313caabd4bcbf”
plot: "A graduate student (Nicholson) copes with a recent breakup by conducti…"
genres: Array
runtime: 80
...
title: "Brief Interviews with Hideous Men"
SCORE: 10.180097579956055 _id: “573a13b2f29313caabd3ab9b”
fullplot: "A man runs into a woman at a wedding. They start to flirt and talk and…"
imdb: Object
year: 2005
...
title: "Conversations with Other Women"
SCORE: 7.147367477416992 _id: “573a1398f29313caabce9a19”
plot: "A man's wife leaves him to take up with an artist, so the man responds…"
genres: Array
runtime: 99
...
title: "Men..."
SCORE: 7.054648399353027 _id: “573a1394f29313caabcde7cc”
plot: "Paralized war vet tries to adjust to the world without the use of his …"
genres: Array
runtime: 85
...
title: "The Men"
SCORE: 7.054648399353027 _id: “573a1399f29313caabced53c”
plot: "Bitter about being double-crossed by the women he loved, (and with the…"
genres: Array
runtime: 105
...
title: "Simple Men"
SCORE: 7.054648399353027 _id: “573a139af29313caabcf0f51”
fullplot: "In a world where both Mutants and Humans fear each other, Marie, bette…"
imdb: Object
year: 2000
...
title: "X-Men"
SCORE: 16.18875503540039 _id: “573a1391f29313caabcd93a3”
plot: "Navy divers clear the torpedo tube of a sunken submarine."
genres: Array
runtime: 77
...
title: "Men Without Women"
SCORE: 15.995916366577148 _id: “573a139af29313caabcf0b12”
plot: "Humberto Fuentes is a wealthy doctor whose wife has recently died. In …"
genres: Array
runtime: 127
...
title: "Men with Guns"
SCORE: 15.995916366577148 _id: “573a13a4f29313caabd1287f”
plot: "Paul Gross stars as the leader of a recently reunited curling team fro…"
genres: Array
runtime: 102
...
title: "Men with Brooms"
SCORE: 15.642412185668945 _id: “573a13c8f29313caabd77ab6”
plot: "Against the tumultuous backdrop of Iran's 1953 CIA-backed coup d'ètat,…"
genres: Array
runtime: 95
...
title: "Women Without Men"
SCORE: 8.15120792388916 _id: “573a13b8f29313caabd4bcbf”
plot: "A graduate student (Nicholson) copes with a recent breakup by conducti…"
genres: Array
runtime: 80
...
title: "Brief Interviews with Hideous Men"
SCORE: 8.118724822998047 _id: “573a13b2f29313caabd3ab9b”
fullplot: "A man runs into a woman at a wedding. They start to flirt and talk and…"
imdb: Object
year: 2005
...
title: "Conversations with Other Women"
SCORE: 8.048237800598145 _id: “573a13a5f29313caabd138ca”
plot: "This documentary, first shown on the Turner Classic Movies cable chann…"
genres: Array
runtime: 56
...
title: "Without Lying Down: Frances Marion and the Power of Women in Hollywood"
SCORE: 7.620831489562988 _id: “573a13c9f29313caabd7ba99”
plot: "The women of a remote Latin American town are forced to pick up the pi…""
genres: Array
runtime: 87
...
title: "Without Men"
SCORE: 4.35431432723999 _id: “573a1393f29313caabcdcd9d”
plot: "A young Canadian nurse (Betsy) comes to the West Indies to care for Je…"
genres: Array
runtime: 69
...
title: "I Walked with a Zombie"
SCORE: 4.35431432723999 _id: “573a1393f29313caabcdd9c7”
plot: "Political intrigue and psychological drama run parallel. The queen is …"
genres: Array
runtime: 93
...
title: "The Eagle with Two Heads"

Search Tester 可能不会显示其所返回文档的所有字段。要查看所有字段,包括在查询路径中指定的字段,请展开结果中的文档。

1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Men Without Women' }
4{ title: 'Brief Interviews with Hideous Men' }
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Getting Even with Dad' }
4{ title: 'Chicken with Plums' }
1{ title: 'Men Without Women' }
2{ title: 'Men with Guns' }
3{ title: 'Men with Brooms' }
4{ title: 'Women Without Men' }
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Men Without Women' }
4{ title: 'Brief Interviews with Hideous Men' }
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Getting Even with Dad' }
4{ title: 'Chicken with Plums' }
1{ title: 'Men Without Women' }
2{ title: 'Men with Guns' }
3{ title: 'Men with Brooms' }
4{ title: 'Women Without Men' }
1{ "title" : "Men with Guns" }
2{ "title" : "Men with Brooms" }
3{ "title" : "Men Without Women" }
4{ "title" : "Brief Interviews with Hideous Men" }
1{ "title" : "Men with Guns" }
2{ "title" : "Men with Brooms" }
3{ "title" : "Getting Even with Dad" }
4{ "title" : "Chicken with Plums" }
1{ "title" : "Men Without Women" }
2{ "title" : "Men with Guns" }
3{ "title" : "Men with Brooms" }
4{ "title" : "Women Without Men" }
1[{title Men with Guns}]
2[{title Men with Brooms}]
3[{title Men Without Women}]
4[{title Brief Interviews with Hideous Men}]
1[{title Men with Guns}]
2[{title Men with Brooms}]
3[{title Getting Even with Dad}]
4[{title Chicken with Plums}]
1[{title Men Without Women}]
2[{title Men with Guns}]
3[{title Men with Brooms}]
4[{title Women Without Men}]
1{"title": "Men with Guns"}
2{"title": "Men with Brooms"}
3{"title": "Men Without Women"}
4{"title": "Brief Interviews with Hideous Men"}
1{"title": "Men with Guns"}
2{"title": "Men with Brooms"}
3{"title": "Getting Even with Dad"}
4{"title": "Chicken with Plums"}
1{"title": "Men Without Women"}
2{"title": "Men with Guns"}
3{"title": "Men with Brooms"}
4{"title": "Women Without Men"}
1Document{{title=Men with Brooms}}
2Document{{title=Men with Guns}}
3Document{{title=Men Without Women}}
4Document{{title=Brief Interviews with Hideous Men}}
1Document{{title=Men with Brooms}}
2Document{{title=Men with Guns}}
3Document{{title=Getting Even with Dad}}
4Document{{title=Chicken with Plums}}
1Document{{title=Men with Guns}}
2Document{{title=Men with Brooms}}
3Document{{title=Men Without Women}}
4Document{{title=Women Without Men}}
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Men Without Women' }
4{ title: 'Brief Interviews with Hideous Men' }
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Getting Even with Dad' }
4{ title: 'Chicken with Plums' }
1{ title: 'Men Without Women' }
2{ title: 'Men with Guns' }
3{ title: 'Men with Brooms' }
4{ title: 'Women Without Men' }
1{'title': 'Men with Guns'}
2{'title': 'Men with Brooms'}
3{'title': 'Men Without Women'}
4{'title': 'Brief Interviews with Hideous Men'}
1{'title': 'Men with Guns'}
2{'title': 'Men with Brooms'}
3{'title': 'Getting Even with Dad'}
4{'title': 'Chicken with Plums'}
1{'title': 'Men Without Women'}
2{'title': 'Men with Brooms'}
3{'title': 'Women Without Men'}
4{'title': 'Men with Guns'}

将以下查询复制并粘贴到 Query Editor 中,然后点击 Query Editor 中的 Search 按钮。

[
{
$search: {
autocomplete: {
path: "title",
query: "men with",
tokenOrder: "sequential"
}
}
}
]

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

db.movies.aggregate([
{
$search: {
"autocomplete": {
"path": "title",
"query": "men with",
"tokenOrder": "sequential"
}
}
},
{
$limit: 4
},
{
$project: {
"_id": 0,
"title": 1
}
}
])

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

movies 集合的 Aggregations 标签页中,从下拉菜单中选择阶段并为该阶段添加查询,以配置以下每个管道阶段。单击 Add Stage 添加其他阶段。

管道阶段
查询

$search

{
"autocomplete": {
"query": "men with",
"path": "title",
"tokenOrder": "sequential"
}
}

$limit

4

$project

{
"_id": 0,
"title": 1,
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;
using MongoDB.Driver.Search;
public class AutocompleteTokenOrderSequentialSimpleExample
{
private const string MongoConnectionString = "<connection-string>";
public static void Main(string[] args)
{
// allow automapping of the camelCase database fields to our MovieDocument
var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
// connect to your Atlas cluster
var mongoClient = new MongoClient(MongoConnectionString);
var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
// define and run pipeline
var results = moviesCollection.Aggregate()
.Search(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Title, "men with", SearchAutocompleteTokenOrder.Sequential))
.Project<MovieDocument>(Builders<MovieDocument>.Projection
.Include(movie => movie.Title)
.Exclude(movie => movie.Id))
.Limit(4)
.ToList();
// print results
foreach (var movie in results)
{
Console.WriteLine(movie.ToJson());
}
}
}
[BsonIgnoreExtraElements]
public class MovieDocument
{
[BsonIgnoreIfDefault]
public ObjectId Id { get; set; }
public string Title { get; set; }
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

package main
import (
"context"
"fmt"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func main() {
// connect to your Atlas cluster
client, err := mongo.Connect(options.Client().ApplyURI("<connection-string>"))
if err != nil {
panic(err)
}
defer client.Disconnect(context.TODO())
// set namespace
collection := client.Database("sample_mflix").Collection("movies")
// define pipeline stages
searchStage := bson.D{{Key: "$search", Value: bson.D{{Key: "autocomplete", Value: bson.D{{Key: "query", Value: "men with"}, {Key: "path", Value: "title"}, {Key: "tokenOrder", Value: "sequential"}}}}}}
limitStage := bson.D{{Key: "$limit", Value: 4}}
projectStage := bson.D{{Key: "$project", Value: bson.D{{Key: "title", Value: 1}, {Key: "_id", Value: 0}}}}
// run pipeline
cursor, err := collection.Aggregate(context.TODO(), mongo.Pipeline{searchStage, limitStage, projectStage})
if err != nil {
panic(err)
}
// print results
var results []bson.D
if err = cursor.All(context.TODO(), &results); err != nil {
panic(err)
}
for _, result := range results {
fmt.Println(result)
}
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import static com.mongodb.client.model.Aggregates.limit;
import static com.mongodb.client.model.Aggregates.project;
import static com.mongodb.client.model.Projections.excludeId;
import static com.mongodb.client.model.Projections.fields;
import static com.mongodb.client.model.Projections.include;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import java.util.Arrays;
public class AutocompleteTokenSequential {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("sample_mflix");
MongoCollection<Document> collection = database.getCollection("movies");
// define pipeline
Document agg = new Document("$search", new Document("autocomplete", new Document("query", "men with").append("path", "title").append("tokenOrder", "sequential")));
// run pipeline and print results
collection.aggregate(Arrays.asList(agg,
limit(4),
project(fields(excludeId(), include("title"))))).forEach(doc -> System.out.println(doc.toJson()));
}
}
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import com.mongodb.client.model.Aggregates.limit
import com.mongodb.client.model.Aggregates.project
import com.mongodb.client.model.Projections.*
import com.mongodb.kotlin.client.coroutine.MongoClient
import kotlinx.coroutines.runBlocking
import org.bson.Document
fun main() {
val uri = "<connection-string>"
val mongoClient = MongoClient.create(uri)
val database = mongoClient.getDatabase("sample_mflix")
val collection = database.getCollection<Document>("movies")
runBlocking {
val agg = Document(
"\$search",
Document(
"autocomplete",
Document("query", "men with")
.append("path", "title")
.append("tokenOrder", "sequential")
)
)
val resultsFlow = collection.aggregate<Document>(
listOf(
agg,
limit(4),
project(fields(excludeId(), include("title")))
)
)
resultsFlow.collect { println(it) }
}
mongoClient.close()
}

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

const { MongoClient } = require("mongodb");
// connect to your Atlas cluster
const uri =
"<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
await client.connect();
// set namespace
const database = client.db("sample_mflix");
const coll = database.collection("movies");
// define pipeline
const agg = [
{$search: {autocomplete: {query: "men with", path: "title", tokenOrder: "sequential"}}},
{$limit: 4},
{$project: {_id: 0,title: 1}}
];
// run pipeline
const result = await coll.aggregate(agg);
// print results
await result.forEach((doc) => console.log(doc));
} finally {
await client.close();
}
}
run().catch(console.dir);

每个查询都包括:

  • $limit 阶段用于将输出限制为 4 个结果。

  • $project 阶段,将排除 title 以外的所有字段。

import pymongo
# connect to your Atlas cluster
client = pymongo.MongoClient('<connection-string>')
# define pipeline
pipeline = [
{"$search": {"autocomplete": {"query": "men with", "path": "title", "tokenOrder": "sequential"}}},
{"$limit": 4},
{"$project": {"_id": 0, "title": 1}},
]
# run pipeline
result = client["sample_mflix"]["movies"].aggregate(pipeline)
# print results
for i in result:
print(i)

注意

结果可能会有所不同

Atlas Search 根据自动完成类型的索引定义中配置的分词策略返回不同的结果。要了解更多信息,请参阅如何为自动完成的字段编制索引。

SCORE: 12.644559860229492 _id: “573a139af29313caabcf0b12”
plot: "Humberto Fuentes is a wealthy doctor whose wife has recently died. In …"
genres: Array
runtime: 127
...
title: "Men with Guns"
SCORE: 12.644559860229492 _id: “573a13a4f29313caabd1287f”
plot: "Paul Gross stars as the leader of a recently reunited curling team fro…"
genres: Array
runtime: 102
...
title: "Men with Brooms"
SCORE: 7.997925281524658 _id: “573a1391f29313caabcd93a3”
plot: "Navy divers clear the torpedo tube of a sunken submarine."
genres: Array
runtime: 77
...
title: "Men Without Women"
SCORE: 11.758549690246582 _id: “573a139af29313caabcf0b12”
plot: "Humberto Fuentes is a wealthy doctor whose wife has recently died. In …"
genres: Array
runtime: 127
...
title: "Men with Guns"
SCORE: 11.758549690246582 _id: “573a13a4f29313caabd1287f”
plot: "Paul Gross stars as the leader of a recently reunited curling team fro…"
genres: Array
runtime: 102
...
title: "Men with Brooms"
SCORE: 7.70704460144043 _id: “573a1399f29313caabcee64e”
plot: "A thief's son cons his father into spending more time with him."
genres: Array
runtime: 109
...
title: "Getting Even with Dad"
SCORE: 7.111915588378906 _id: “573a13cdf29313caabd844f5”
plot: "Since his beloved violin was broken, Nasser Ali Khan, one of the most …"
genres: Array
runtime: 93
...
title: "Chicken with Plums"
SCORE: 7.928277015686035 _id: “573a1391f29313caabcd93a3”
plot: "Navy divers clear the torpedo tube of a sunken submarine."
genres: Array
runtime: 77
...
title: "Men Without Women"
SCORE: 7.928277015686035 _id: “573a139af29313caabcf0b12”
plot: "Humberto Fuentes is a wealthy doctor whose wife has recently died. In …"
genres: Array
runtime: 127
...
title: "Men with Guns"
SCORE: 7.928277015686035 _id: “573a13a4f29313caabd1287f”
plot: "Paul Gross stars as the leader of a recently reunited curling team fro…"
genres: Array
runtime: 102
...
title: "Men with Brooms"
SCORE: 7.381933212280273 _id: “573a13c8f29313caabd77ab6”
plot: "Against the tumultuous backdrop of Iran's 1953 CIA-backed coup d'ètat,…"
genres: Array
runtime: 95
...
title: "Women Without Men"

Search Tester 可能不会显示其所返回文档的所有字段。要查看所有字段,包括在查询路径中指定的字段,请展开结果中的文档。

1{ title: 'Men with Guns' },
2{ title: 'Men with Brooms' },
3{ title: 'Men Without Women' }
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Getting Even with Dad' }
4{ title: 'Chicken with Plums' }
1{ title: 'Men Without Women' },
2{ title: 'Men with Guns' },
3{ title: 'Men with Brooms' },
4{ title: 'Women Without Men' }
1{ title: 'Men with Guns' },
2{ title: 'Men with Brooms' },
3{ title: 'Men Without Women' }
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Getting Even with Dad' }
4{ title: 'Chicken with Plums' }
1{ title: 'Men Without Women' },
2{ title: 'Men with Guns' },
3{ title: 'Men with Brooms' },
4{ title: 'Women Without Men' }
1{"title": "Men with Guns"}
2{"title": "Men with Brooms"}
3{"title": "Men Without Women"}
1{ "title" : "Men with Guns" }
2{ "title" : "Men with Brooms" }
3{ "title" : "Getting Even with Dad" }
4{ "title" : "Chicken with Plums" }
1{ "title" : "Men Without Women" }
2{ "title" : "Men with Guns" }
3{ "title" : "Men with Brooms" }
4{ "title" : "Women Without Men" }
1[{title Men with Guns}]
2[{title Men with Brooms}]
3[{title Men Without Women}]
1[{title Men with Guns}]
2[{title Men with Brooms}]
3[{title Getting Even with Dad}]
4[{title Chicken with Plums}]
1[{title Men Without Women}]
2[{title Men with Guns}]
3[{title Men with Brooms}]
4[{title Women Without Men}]
1{"title": "Men with Guns"}
2{"title": "Men with Brooms"}
3{"title": "Men Without Women"}
1{ "title" : "Men with Guns" }
2{ "title" : "Men with Brooms" }
3{ "title" : "Getting Even with Dad" }
4{ "title" : "Chicken with Plums" }
1{"title": "Men Without Women"}
2{"title": "Men with Guns"}
3{"title": "Men with Brooms"}
4{"title": "Women Without Men"}
1Document{{title=Men with Brooms}}
2Document{{title=Men with Guns}}
3Document{{title=Men Without Women}}
1Document{{title=Men with Brooms}}
2Document{{title=Men with Guns}}
3Document{{title=Getting Even with Dad}}
4Document{{title=Chicken with Plums}}
1Document{{title=Men with Guns}}
2Document{{title=Men with Brooms}}
3Document{{title=Men Without Women}}
4Document{{title=Women Without Men}}
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Men Without Women' }
1{ title: 'Men with Guns' }
2{ title: 'Men with Brooms' }
3{ title: 'Getting Even with Dad' }
4{ title: 'Chicken with Plums' }
1{ title: 'Men Without Women' }
2{ title: 'Men with Guns' }
3{ title: 'Men with Brooms' }
4{ title: 'Women Without Men' }
1{'title': 'Men with Guns'}
2{'title': 'Men with Brooms'}
3{'title': 'Men Without Women'}
1{'title': 'Men with Guns'}
2{'title': 'Men with Brooms'}
3{'title': 'Getting Even with Dad'}
4{'title': 'Chicken with Plums'}
1{'title': 'Men Without Women'}
2{'title': 'Men with Guns'}
3{'title': 'Men with Brooms'}
4{'title': 'Women Without Men'}

以下查询在movies 集合的 title 字段中搜索 ger 字符,并为 title 字段启用了 highlight 选项。

重要

要突出显示 autocomplete 已索引版本的路径,autocomplete 运算符必须是唯一在此查询中使用该路径的运算符。

将以下查询复制并粘贴到 Query Editor 中,然后点击 Query Editor 中的 Search 按钮。

[
{
$search: {
autocomplete: {
path: "title",
query: "ger"
},
highlight: {
path: "title"
}
}
}
]

查询包括:

  • $limit 阶段用于将输出限制为 5 个结果。

  • $project 阶段到:

    • 返回文档的分数。

    • 排除 title 以外的所有字段。

    • 添加一个名为 highlights 的新字段,其中包含突出显示的信息。

db.movies.aggregate([
{
$search: {
"autocomplete": {
"path": "title",
"query": ["ger"]
},
"highlight": {
"path": "title"
}
}
},
{
$limit: 5
},
{
$project: {
"score": { $meta: "searchScore" },
"title": 1,
"_id": 0,
"highlights": { "$meta": "searchHighlights" }
}
}
])

查询包括:

  • $limit 阶段用于将输出限制为 5 个结果。

  • $project 阶段到:

    • 返回文档的分数。

    • 排除 title 以外的所有字段。

    • 添加一个名为 highlights 的新字段,其中包含突出显示的信息。

movies 集合的 Aggregations 标签页中,从下拉菜单中选择阶段并为该阶段添加查询,以配置以下每个管道阶段。单击 Add Stage 添加其他阶段。

管道阶段
查询

$search

{
"autocomplete": {
"path": "title",
"query": ["ger"]
},
"highlight": {
"path": "title"
}
}

$limit

5

$project

{
"score": { $meta: "searchScore" },
"title": 1,
"_id": 0,
"highlights": { "$meta": "searchHighlights" }
}

查询包括:

  • $limit 阶段用于将输出限制为 5 个结果。

  • $project 阶段到:

    • 返回文档的分数。

    • 排除 title 以外的所有字段。

    • 添加一个名为 highlights 的新字段,其中包含突出显示的信息。

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;
using MongoDB.Driver.Search;
public class AutocompleteHighlightExample
{
private const string MongoConnectionString = "<connection-string>";
public static void Main(string[] args)
{
// allow automapping of the camelCase database fields to our MovieDocument
var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
// connect to your Atlas cluster
var mongoClient = new MongoClient(MongoConnectionString);
var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
// define and run pipeline
var results = moviesCollection.Aggregate()
.Search(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Title, "ger"), new SearchHighlightOptions<MovieDocument>(movie => movie.Title))
.Project<MovieDocument>(Builders<MovieDocument>.Projection
.Include(movie => movie.Title)
.Exclude(movie => movie.Id)
.MetaSearchScore(movie => movie.Score)
.MetaSearchHighlights("highlights"))
.Limit(5)
.ToList();
// print results
foreach (var movie in results)
{
Console.WriteLine(movie.ToJson());
}
}
}
[BsonIgnoreExtraElements]
public class MovieDocument
{
[BsonIgnoreIfDefault]
public ObjectId Id { get; set; }
public string Title { get; set; }
[BsonElement("highlights")]
public List<SearchHighlight> Highlights { get; set; }
public double Score { get; set; }
}

查询包括:

  • $limit 阶段用于将输出限制为 5 个结果。

  • $project 阶段到:

    • 返回文档的分数。

    • 排除 title 以外的所有字段。

    • 添加一个名为 highlights 的新字段,其中包含突出显示的信息。

package main
import (
"context"
"fmt"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func main() {
// connect to your Atlas cluster
client, err := mongo.Connect(options.Client().ApplyURI("<connection-string>"))
if err != nil {
panic(err)
}
defer client.Disconnect(context.TODO())
// set namespace
collection := client.Database("sample_mflix").Collection("movies")
// define pipeline stages
searchStage := bson.D{{Key: "$search", Value: bson.D{{Key: "autocomplete", Value: bson.M{"query": "ger", "path": "title"}}, {Key: "highlight", Value: bson.D{{Key: "path", Value: "title"}}}}}}
limitStage := bson.D{{Key: "$limit", Value: 5}}
projectStage := bson.D{{Key: "$project", Value: bson.D{{Key: "score", Value: bson.D{{Key: "$meta", Value: "searchScore"}}}, {Key: "title", Value: 1}, {Key: "_id", Value: 0}, {Key: "highlight", Value: bson.D{{Key: "$meta", Value: "searchHighlights"}}}}}}
// run pipeline
cursor, err := collection.Aggregate(context.TODO(), mongo.Pipeline{searchStage, limitStage, projectStage})
if err != nil {
panic(err)
}
// print results
var results []bson.D
if err = cursor.All(context.TODO(), &results); err != nil {
panic(err)
}
for _, result := range results {
fmt.Println(result)
}
}

查询包括:

  • $limit 阶段用于将输出限制为 5 个结果。

  • $project 阶段到:

    • 返回文档的分数。

    • 排除 title 以外的所有字段。

    • 添加一个名为 highlights 的新字段,其中包含突出显示的信息。

import static com.mongodb.client.model.Aggregates.limit;
import static com.mongodb.client.model.Aggregates.project;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import java.util.Arrays;
public class AutocompleteHighlight {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("sample_mflix");
MongoCollection<Document> collection = database.getCollection("movies");
// define pipeline
Document agg = new Document("$search", new Document("autocomplete", new Document("path", "title").append("query", Arrays.asList("ger")))
.append("highlight", new Document("path", "title")));
// run pipeline and print results
collection.aggregate(Arrays.asList(agg,
limit(5),
project(Document.parse("{score: {$meta: 'searchScore'}, _id: 0, title: 1, highlights: {$meta: 'searchHighlights'}}"))))
.forEach(doc -> System.out.println(doc.toJson()));
}
}
}

查询包括:

  • $limit 阶段用于将输出限制为 5 个结果。

  • $project 阶段到:

    • 返回文档的分数。

    • 排除 title 以外的所有字段。

    • 添加一个名为 highlights 的新字段,其中包含突出显示的信息。

import com.mongodb.client.model.Aggregates.limit
import com.mongodb.client.model.Aggregates.project
import com.mongodb.client.model.Projections.*
import com.mongodb.kotlin.client.coroutine.MongoClient
import kotlinx.coroutines.runBlocking
import org.bson.Document
fun main() {
val uri = "<connection-string>"
val mongoClient = MongoClient.create(uri)
val database = mongoClient.getDatabase("sample_mflix")
val collection = database.getCollection<Document>("movies")
runBlocking {
val agg = Document(
"\$search", Document("autocomplete", Document("path", "title")
.append("query", listOf("ger"))
).append("highlight", Document("path", "title"))
)
val resultsFlow = collection.aggregate<Document>(
listOf(
agg,
limit(5),
project(fields(
excludeId(),
include("title"),
computed("score", Document("\$meta", "searchScore")),
computed("highlights", Document("\$meta", "searchHighlights"))
))
)
)
resultsFlow.collect { println(it) }
}
mongoClient.close()
}

查询包括:

  • $limit 阶段用于将输出限制为 5 个结果。

  • $project 阶段到:

    • 返回文档的分数。

    • 排除 title 以外的所有字段。

    • 添加一个名为 highlights 的新字段,其中包含突出显示的信息。

const { MongoClient } = require("mongodb");
// connect to your Atlas cluster
const uri =
"<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
await client.connect();
// set namespace
const database = client.db("sample_mflix");
const coll = database.collection("movies");
// define pipeline
const agg = [
{$search: {autocomplete: {query: "ger", path: "title"}, highlight:{path: "title"}}},
{$limit: 5},
{$project: {score: {$meta: "searchScore"}, _id: 0,title: 1, highlights: {$meta: "searchHighlights"}}}
];
// run pipeline
const result = coll.aggregate(agg);
// print results
result.forEach((doc) => console.dir(JSON.stringify(doc)));
} finally {
await client.close();
}
}
run().catch(console.dir);

查询包括:

  • $limit 阶段用于将输出限制为 5 个结果。

  • $project 阶段到:

    • 返回文档的分数。

    • 排除 title 以外的所有字段。

    • 添加一个名为 highlights 的新字段,其中包含突出显示的信息。

import pymongo
# connect to your Atlas cluster
client = pymongo.MongoClient('<connection-string>')
# define pipeline
pipeline = [
{"$search":{"autocomplete": {"query": "ger", "path": "title"}, "highlight": {"path": "title"}}},
{"$limit": 5},
{"$project": {"score": {"$meta": "searchScore"},"_id": 0, "title": 1, "highlights": {"$meta": "searchHighlights"}}},
]
# run pipeline
result = client["sample_mflix"]["movies"].aggregate(pipeline)
# print results
for i in result:
print(i)

注意

结果可能会有所不同

Atlas Search 根据自动完成类型的索引定义中配置的分词策略返回不同的结果。要了解更多信息,请参阅如何为自动完成的字段编制索引。

SCORE: 6.0822906494140625 _id: “573a1390f29313caabcd50e5”
Gertie the Dinosaur
Matching fields: title
SCORE: 6.0822906494140625 _id: “573a1393f29313caabcddae1”
Germany Year Zero
Matching fields: title
SCORE: 6.0822906494140625 _id: “573a1397f29313caabce6b75”
Germany in Autumn
Matching fields: title
SCORE: 6.0822906494140625 _id: “573a1397f29313caabce77b5”
Germany Pale Mother
Matching fields: title
SCORE: 6.0822906494140625 _id: “573a13d4f29313caabd99fa2”
Gerhard Richter - Painting
Matching fields: title
SCORE: 6.018838405609131 _id: “573a1399f29313caabcedb50”
Geronimo: An American Legend
Matching fields: title
SCORE: 5.825854301452637 _id: “573a139bf29313caabcf36bd”
Geri's Game
Matching fields: title
SCORE: 5.777737617492676 _id: “573a13a5f29313caabd15dae”
How to Live in the German Federal Republic
Matching fields: title
SCORE: 5.738928318023682 _id: “573a13b4f29313caabd41bb7”
The Gerson Miracle
Matching fields: title
SCORE: 5.738928318023682 _id: “573a13d2f29313caabd922de”
The German Doctor
Matching fields: title
SCORE: 4.7550506591796875 _id: “573a139df29313caabcf9ed2”
South Park: Bigger Longer & Uncut
Matching fields: title
SCORE: 4.568849563598633 _id: “573a13a7f29313caabd1addf”
Roger Dodger
Matching fields: title
SCORE: 4.520683288574219 _id: “573a1391f29313caabcd8783”
The Jazz Singer
Matching fields: title
SCORE: 4.520683288574219 _id: “573a1396f29313caabce3974”
Love and Anger
Matching fields: title
SCORE: 4.520683288574219 _id: “573a1396f29313caabce5212”
Save the Tiger
Matching fields: title
SCORE: 4.520683288574219 _id: “573a1397f29313caabce78da”
The Jazz Singer
Matching fields: title
SCORE: 4.520683288574219 _id: “573a1398f29313caabce9be6”
The Toxic Avenger
Matching fields: title
SCORE: 4.520683288574219 _id: “573a139af29313caabcf0f59”
The Wedding Singer
Matching fields: title
SCORE: 4.520683288574219 _id: “573a139af29313caabcf1389”
The Crazy Stranger
Matching fields: title
SCORE: 4.520683288574219 _id: “573a13abf29313caabd24b5a”
Save the Tiger
Matching fields: title
SCORE: 4.371164321899414 _id: “573a139df29313caabcf9ed2”
South Park: Bigger Longer & Uncut
Matching fields: title
SCORE: 4.3067307472229 _id: “573a13bff29313caabd60a4a”
Bigger Stronger Faster*
Matching fields: title
SCORE: 4.26673698425293 _id: “573a1398f29313caabcebb00”
The Toxic Avenger Part II
Matching fields: title
SCORE: 4.26673698425293 _id: “573a1399f29313caabcee12e”
When a Stranger Calls Back
Matching fields: title
SCORE: 4.26673698425293 _id: “573a13cff29313caabd89c2b”
Carol Channing: Larger Than Life
Matching fields: title
SCORE: 4.2623162269592285 _id: “573a1396f29313caabce51c6”
Property Is No Longer a Theft
Matching fields: title
SCORE: 4.2623162269592285 _id: “573a139af29313caabcef539”
Mighty Morphin Power Rangers: The Movie
Matching fields: title
SCORE: 4.2623162269592285 _id: “573a13b1f29313caabd364e3”
Josee, the Tiger and the Fish
Matching fields: title
SCORE: 4.253501892089844 _id: “573a13a5f29313caabd15dae”
How to Live in the German Federal Republic
Matching fields: title
SCORE: 4.24910831451416 _id: “573a13a3f29313caabd0f07f”
Into the Arms of Strangers: Stories of the Kindertransport
Matching fields: title

Search Tester 可能不会显示其所返回文档的所有字段。要查看所有字段,包括在查询路径中指定的字段,请展开结果中的文档。

1{
2 title: 'Gertie the Dinosaur',
3 score: 6.085907459259033,
4 highlights: [{
5 score: 0.9227690100669861,
6 path: 'title',
7 texts: [ { value: 'Gertie the Dinosaur', type: 'hit' } ]
8 }]
9},
10{
11 title: 'Germany Year Zero',
12 score: 6.085907459259033,
13 highlights: [{
14 score: 0.9180012345314026,
15 path: 'title',
16 texts: [ { value: 'Germany Year Zero', type: 'hit' } ]
17 }]
18},
19{
20 title: 'Germany in Autumn',
21 score: 6.085907459259033,
22 highlights: [{
23 score: 0.9180012345314026,
24 path: 'title',
25 texts: [ { value: 'Germany in Autumn', type: 'hit' } ]
26 }]
27},
28{
29 title: 'Germany Pale Mother',
30 score: 6.085907459259033,
31 highlights: [{
32 score: 0.9227690100669861,
33 path: 'title',
34 texts: [ { value: 'Germany Pale Mother', type: 'hit' } ]
35 }]
36},
37{
38 title: 'Gerhard Richter - Painting',
39 score: 6.085907459259033,
40 highlights: [{
41 score: 0.9386774897575378,
42 path: 'title',
43 texts: [ { value: 'Gerhard Richter - Painting', type: 'hit' } ]
44 }]
45}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的左侧。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 title: 'South Park: Bigger Longer & Uncut',
3 score: 4.807340621948242,
4 highlights: [{
5 score: 0.6177878975868225,
6 path: 'title',
7 texts: [
8 { value: 'South Park: Bigger Longer', type: 'hit' },
9 { value: ' & Uncut', type: 'text' } ]
10 }]
11},
12{
13 title: 'Roger Dodger',
14 score: 4.6073713302612305,
15 highlights: [{
16 score: 0.905626654624939,
17 path: 'title',
18 texts: [ { value: 'Roger Dodger', type: 'hit' } ]
19 }]
20},
21{
22 title: 'The Jazz Singer',
23 score: 4.577486038208008,
24 highlights: [{
25 score: 0.9131305813789368,
26 path: 'title',
27 texts: [ { value: 'The Jazz Singer', type: 'hit' } ]
28 }]
29},
30{
31 title: 'Love and Anger',
32 score: 4.577486038208008,
33 highlights: [{
34 score: 0.9106559753417969,
35 path: 'title',
36 texts: [ { value: 'Love and Anger', type: 'hit' } ]
37 }]
38},
39{
40 title: 'Save the Tiger',
41 score: 4.577486038208008,
42 highlights: [{
43 score: 0.9106559753417969,
44 path: 'title',
45 texts: [ { value: 'Save the Tiger', type: 'hit' } ]
46 }]
47}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的右侧。当突出显示的路径仅在突出显示的查询的 autocomplete 操作符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 title: 'South Park: Bigger Longer & Uncut',
3 score: 4.365298748016357,
4 highlights: [{
5 score: 0.38510727882385254,
6 path: 'title',
7 texts: [ { value: 'South Park: Bigger Longer & Uncut', type: 'hit' } ]
8 }]
9},
10{
11 title: 'Bigger Stronger Faster*',
12 score: 4.300583839416504,
13 highlights: [{
14 score: 0.5282801985740662,
15 path: 'title',
16 texts: [
17 { value: 'Bigger Stronger Faster', type: 'hit' },
18 { value: '*', type: 'text' }
19 ]
20 }]
21},
22{
23 title: 'The Toxic Avenger Part II',
24 score: 4.2650651931762695,
25 highlights: [{
26 score: 0.5984020829200745,
27 path: 'title',
28 texts: [ { value: 'The Toxic Avenger Part II', type: 'hit' } ]
29 }]
30},
31{
32 title: 'When a Stranger Calls Back',
33 score: 4.2650651931762695,
34 highlights: [{
35 score: 0.6008684039115906,
36 path: 'title',
37 texts: [ { value: 'When a Stranger Calls Back', type: 'hit' } ]
38 }]
39},
40{
41 title: 'Carol Channing: Larger Than Life',
42 score: 4.2650651931762695,
43 highlights: [{
44 score: 0.6154072880744934,
45 path: 'title',
46 texts: [ { value: 'Carol Channing: Larger Than Life', type: 'hit' } ]
47 }]
48}

Atlas Search 会返回这些结果,因为字符 ger 出现在标题的不同位置。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 title: 'Gertie the Dinosaur',
3 score: 6.085907459259033,
4 highlights: [{
5 score: 0.9227690100669861,
6 path: 'title',
7 texts: [ { value: 'Gertie the Dinosaur', type: 'hit' } ]
8 }]
9},
10{
11 title: 'Germany Year Zero',
12 score: 6.085907459259033,
13 highlights: [{
14 score: 0.9180012345314026,
15 path: 'title',
16 texts: [ { value: 'Germany Year Zero', type: 'hit' } ]
17 }]
18},
19{
20 title: 'Germany in Autumn',
21 score: 6.085907459259033,
22 highlights: [{
23 score: 0.9180012345314026,
24 path: 'title',
25 texts: [ { value: 'Germany in Autumn', type: 'hit' } ]
26 }]
27},
28{
29 title: 'Germany Pale Mother',
30 score: 6.085907459259033,
31 highlights: [{
32 score: 0.9227690100669861,
33 path: 'title',
34 texts: [ { value: 'Germany Pale Mother', type: 'hit' } ]
35 }]
36},
37{
38 title: 'Gerhard Richter - Painting',
39 score: 6.085907459259033,
40 highlights: [{
41 score: 0.9386774897575378,
42 path: 'title',
43 texts: [ { value: 'Gerhard Richter - Painting', type: 'hit' } ]
44 }]
45}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的左侧。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 title: 'South Park: Bigger Longer & Uncut',
3 score: 4.807340621948242,
4 highlights: [{
5 score: 0.6177878975868225,
6 path: 'title',
7 texts: [
8 { value: 'South Park: Bigger Longer', type: 'hit' },
9 { value: ' & Uncut', type: 'text' } ]
10 }]
11},
12{
13 title: 'Roger Dodger',
14 score: 4.6073713302612305,
15 highlights: [{
16 score: 0.905626654624939,
17 path: 'title',
18 texts: [ { value: 'Roger Dodger', type: 'hit' } ]
19 }]
20},
21{
22 title: 'The Jazz Singer',
23 score: 4.577486038208008,
24 highlights: [{
25 score: 0.9131305813789368,
26 path: 'title',
27 texts: [ { value: 'The Jazz Singer', type: 'hit' } ]
28 }]
29},
30{
31 title: 'Love and Anger',
32 score: 4.577486038208008,
33 highlights: [{
34 score: 0.9106559753417969,
35 path: 'title',
36 texts: [ { value: 'Love and Anger', type: 'hit' } ]
37 }]
38},
39{
40 title: 'Save the Tiger',
41 score: 4.577486038208008,
42 highlights: [{
43 score: 0.9106559753417969,
44 path: 'title',
45 texts: [ { value: 'Save the Tiger', type: 'hit' } ]
46 }]
47}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的右侧。当突出显示的路径仅在突出显示的查询的 autocomplete 操作符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 title: 'South Park: Bigger Longer & Uncut',
3 score: 4.365298748016357,
4 highlights: [{
5 score: 0.38510727882385254,
6 path: 'title',
7 texts: [ { value: 'South Park: Bigger Longer & Uncut', type: 'hit' } ]
8 }]
9},
10{
11 title: 'Bigger Stronger Faster*',
12 score: 4.300583839416504,
13 highlights: [{
14 score: 0.5282801985740662,
15 path: 'title',
16 texts: [
17 { value: 'Bigger Stronger Faster', type: 'hit' },
18 { value: '*', type: 'text' }
19 ]
20 }]
21},
22{
23 title: 'The Toxic Avenger Part II',
24 score: 4.2650651931762695,
25 highlights: [{
26 score: 0.5984020829200745,
27 path: 'title',
28 texts: [ { value: 'The Toxic Avenger Part II', type: 'hit' } ]
29 }]
30},
31{
32 title: 'When a Stranger Calls Back',
33 score: 4.2650651931762695,
34 highlights: [{
35 score: 0.6008684039115906,
36 path: 'title',
37 texts: [ { value: 'When a Stranger Calls Back', type: 'hit' } ]
38 }]
39},
40{
41 title: 'Carol Channing: Larger Than Life',
42 score: 4.2650651931762695,
43 highlights: [{
44 score: 0.6154072880744934,
45 path: 'title',
46 texts: [ { value: 'Carol Channing: Larger Than Life', type: 'hit' } ]
47 }]
48}

Atlas Search 会返回这些结果,因为字符 ger 出现在标题的不同位置。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{ "title" : "Gertie the Dinosaur", "highlights" : [{ "path" : "title", "score" : 0.92276901006698608, "texts" : [{ "type" : "Hit", "value" : "Gertie the Dinosaur" }] }], "score" : 6.0822906494140625 }
2{ "title" : "Germany Year Zero", "highlights" : [{ "path" : "title", "score" : 0.91800123453140259, "texts" : [{ "type" : "Hit", "value" : "Germany Year Zero" }] }], "score" : 6.0822906494140625 }
3{ "title" : "Germany in Autumn", "highlights" : [{ "path" : "title", "score" : 0.91800123453140259, "texts" : [{ "type" : "Hit", "value" : "Germany in Autumn" }] }], "score" : 6.0822906494140625 }
4{ "title" : "Germany Pale Mother", "highlights" : [{ "path" : "title", "score" : 0.92276901006698608, "texts" : [{ "type" : "Hit", "value" : "Germany Pale Mother" }] }], "score" : 6.0822906494140625 }
5{ "title" : "Gerhard Richter - Painting", "highlights" : [{ "path" : "title", "score" : 0.93867748975753784, "texts" : [{ "type" : "Hit", "value" : "Gerhard Richter - Painting" }] }], "score" : 6.0822906494140625 }

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的左侧。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{ "title" : "South Park: Bigger Longer & Uncut", "highlights" : [{ "path" : "title", "score" : 0.61778789758682251, "texts" : [{ "type" : "Hit", "value" : "South Park: Bigger Longer" }, { "type" : "Text", "value" : " & Uncut" }] }], "score" : 4.7550506591796875 }
2{ "title" : "Roger Dodger", "highlights" : [{ "path" : "title", "score" : 0.90562665462493896, "texts" : [{ "type" : "Hit", "value" : "Roger Dodger" }] }], "score" : 4.5688495635986328 }
3{ "title" : "The Jazz Singer", "highlights" : [{ "path" : "title", "score" : 0.91313058137893677, "texts" : [{ "type" : "Hit", "value" : "The Jazz Singer" }] }], "score" : 4.5206832885742188 }
4{ "title" : "Love and Anger", "highlights" : [{ "path" : "title", "score" : 0.91065597534179688, "texts" : [{ "type" : "Hit", "value" : "Love and Anger" }] }], "score" : 4.5206832885742188 }
5{ "title" : "Save the Tiger", "highlights" : [{ "path" : "title", "score" : 0.91065597534179688, "texts" : [{ "type" : "Hit", "value" : "Save the Tiger" }] }], "score" : 4.5206832885742188 }

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的右侧。当突出显示的路径仅在突出显示的查询的 autocomplete 操作符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{ "title" : "South Park: Bigger Longer & Uncut", "highlights" : [{ "path" : "title", "score" : 0.38510727882385254, "texts" : [{ "type" : "Hit", "value" : "South Park: Bigger Longer & Uncut" }] }], "score" : 4.3711643218994141 }
2{ "title" : "Bigger Stronger Faster*", "highlights" : [{ "path" : "title", "score" : 0.52828019857406616, "texts" : [{ "type" : "Hit", "value" : "Bigger Stronger Faster" }, { "type" : "Text", "value" : "*" }] }], "score" : 4.3067307472229004 }
3{ "title" : "The Toxic Avenger Part II", "highlights" : [{ "path" : "title", "score" : 0.59840208292007446, "texts" : [{ "type" : "Hit", "value" : "The Toxic Avenger Part II" }] }], "score" : 4.2667369842529297 }
4{ "title" : "When a Stranger Calls Back", "highlights" : [{ "path" : "title", "score" : 0.60086840391159058, "texts" : [{ "type" : "Hit", "value" : "When a Stranger Calls Back" }] }], "score" : 4.2667369842529297 }
5{ "title" : "Carol Channing: Larger Than Life", "highlights" : [{ "path" : "title", "score" : 0.61540728807449341, "texts" : [{ "type" : "Hit", "value" : "Carol Channing: Larger Than Life" }] }], "score" : 4.2667369842529297 }

Atlas Search 会返回这些结果,因为字符 ger 出现在标题的不同位置。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1[
2 {title Gertie the Dinosaur}
3 {score 6.085907459259033}
4 {highlight [[
5 {score 0.9227690100669861}
6 {path title}
7 {texts [[{value Gertie the Dinosaur} {type hit}]]}]]}]
8[
9 {title Germany Year Zero}
10 {score 6.085907459259033}
11 {highlight [[
12 {score 0.9180012345314026}
13 {path title}
14 {texts [[{value Germany Year Zero} {type hit}]]}]]}]
15[
16 {title Germany in Autumn}
17 {score 6.085907459259033}
18 {highlight [[
19 {score 0.9180012345314026}
20 {path title}
21 {texts [[{value Germany in Autumn} {type hit}]]}]]}]
22[
23 {title Germany Pale Mother}
24 {score 6.085907459259033}
25 {highlight [[
26 {score 0.9227690100669861}
27 {path title}
28 {texts [[{value Germany Pale Mother} {type hit}]]}]]}]
29[
30 {title Gerhard Richter - Painting}
31 {score 6.085907459259033}
32 {highlight [[
33 {score 0.9386774897575378}
34 {path title}
35 {texts [[{value Gerhard Richter - Painting} {type hit}]]}]]}]

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的左侧。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1[
2 {title South Park: Bigger Longer & Uncut}
3 {score 4.807340621948242}
4 {highlight [[
5 {score 0.6177878975868225}
6 {path title}
7 {texts [[{value South Park: Bigger Longer} {type hit}] [{value & Uncut} {type text}]]}]]}]
8[
9 {title Roger Dodger}
10 {score 4.6073713302612305}
11 {highlight [[
12 {score 0.905626654624939}
13 {path title}
14 {texts [[{value Roger Dodger} {type hit}]]}]]}]
15[
16 {title The Jazz Singer}
17 {score 4.577486038208008}
18 {highlight [[
19 {score 0.9131305813789368}
20 {path title}
21 {texts [[{value The Jazz Singer} {type hit}]]}]]}]
22[
23 {title Love and Anger}
24 {score 4.577486038208008}
25 {highlight [[
26 {score 0.9106559753417969}
27 {path title}
28 {texts [[{value Love and Anger} {type hit}]]}]]}]
29[
30 {title Save the Tiger}
31 {score 4.577486038208008}
32 {highlight [[
33 {score 0.9106559753417969}
34 {path title}
35 {texts [[{value Save the Tiger} {type hit}]]}]]}]

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的右侧。当突出显示的路径仅在突出显示的查询的 autocomplete 操作符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1[
2 {title South Park: Bigger Longer & Uncut}
3 {score 4.365298748016357}
4 {highlight [[
5 {score 0.38510727882385254}
6 {path title}
7 {texts [[{value South Park: Bigger Longer & Uncut} {type hit}]]}]]}]
8[
9 {title Bigger Stronger Faster*} {
10 score 4.300583839416504}
11 {highlight [[
12 {score 0.5282801985740662}
13 {path title}
14 {texts [[{value Bigger Stronger Faster} {type hit}] [{value *} {type text}]]}]]}]
15[
16 {title The Toxic Avenger Part II}
17 {score 4.2650651931762695}
18 {highlight [[
19 {score 0.5984020829200745}
20 {path title}
21 {texts [[{value The Toxic Avenger Part II} {type hit}]]}]]}]
22[
23 {title When a Stranger Calls Back}
24 {score 4.2650651931762695}
25 {highlight [[
26 {score 0.6008684039115906}
27 {path title}
28 {texts [[{value When a Stranger Calls Back} {type hit}]]}]]}]
29[
30 {title Carol Channing: Larger Than Life}
31 {score 4.2650651931762695}
32 {highlight [[
33 {score 0.6154072880744934}
34 {path title}
35 {texts [[{value Carol Channing: Larger Than Life} {type hit}]]}]]}]

Atlas Search 会返回这些结果,因为字符 ger 出现在标题的不同位置。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 "title": "Gertie the Dinosaur",
3 "score": 6.085907459259033,
4 "highlights": [{
5 "score": 0.9227690100669861,
6 "path": "title",
7 "texts": [{"value": "Gertie the Dinosaur", "type": "hit"}]}]}
8{
9 "title": "Germany Year Zero",
10 "score": 6.085907459259033,
11 "highlights": [{
12 "score": 0.9180012345314026,
13 "path": "title",
14 "texts": [{"value": "Germany Year Zero", "type": "hit"}]}]}
15{
16 "title": "Germany in Autumn",
17 "score": 6.085907459259033,
18 "highlights": [{
19 "score": 0.9180012345314026,
20 "path": "title",
21 "texts": [{"value": "Germany in Autumn", "type": "hit"}]}]}
22{
23 "title": "Germany Pale Mother",
24 "score": 6.085907459259033,
25 "highlights": [{
26 "score": 0.9227690100669861,
27 "path": "title",
28 "texts": [{"value": "Germany Pale Mother", "type": "hit"}]}]}
29{
30 "title": "Gerhard Richter - Painting",
31 "score": 6.085907459259033,
32 "highlights": [{
33 "score": 0.9386774897575378,
34 "path": "title",
35 "texts": [{"value": "Gerhard Richter - Painting", "type": "hit"}]}]}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的左侧。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 "title": "South Park: Bigger Longer & Uncut",
3 "score": 4.807340621948242,
4 "highlights": [{
5 "score": 0.6177878975868225,
6 "path": "title",
7 "texts": [{"value": "South Park: Bigger Longer", "type": "hit"}, {"value": " & Uncut", "type": "text"}]}]}
8{
9 "title": "Roger Dodger",
10 "score": 4.6073713302612305,
11 "highlights": [{
12 "score": 0.905626654624939,
13 "path": "title",
14 "texts": [{"value": "Roger Dodger", "type": "hit"}]}]}
15{
16 "title": "The Jazz Singer",
17 "score": 4.577486038208008,
18 "highlights": [{
19 "score": 0.9131305813789368,
20 "path": "title",
21 "texts": [{"value": "The Jazz Singer", "type": "hit"}]}]}
22{
23 "title": "Love and Anger",
24 "score": 4.577486038208008,
25 "highlights": [{
26 "score": 0.9106559753417969,
27 "path": "title",
28 "texts": [{"value": "Love and Anger", "type": "hit"}]}]}
29{
30 "title": "Save the Tiger",
31 "score": 4.577486038208008,
32 "highlights": [{
33 "score": 0.9106559753417969,
34 "path": "title",
35 "texts": [{"value": "Save the Tiger", "type": "hit"}]}]}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的右侧。当突出显示的路径仅在突出显示的查询的 autocomplete 操作符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 "title": "South Park: Bigger Longer & Uncut",
3 "score": 4.365298748016357,
4 "highlights": [{
5 "score": 0.38510727882385254,
6 "path": "title",
7 "texts": [{"value": "South Park: Bigger Longer & Uncut", "type": "hit"}]}]}
8{
9 "title": "Bigger Stronger Faster*",
10 "score": 4.300583839416504,
11 "highlights": [{
12 "score": 0.5282801985740662,
13 "path": "title",
14 "texts": [{"value": "Bigger Stronger Faster", "type": "hit"}, {"value": "*", "type": "text"}]}]}
15{
16 "title": "The Toxic Avenger Part II",
17 "score": 4.2650651931762695,
18 "highlights": [{
19 "score": 0.5984020829200745,
20 "path": "title",
21 "texts": [{"value": "The Toxic Avenger Part II", "type": "hit"}]}]}
22{
23 "title": "When a Stranger Calls Back",
24 "score": 4.2650651931762695,
25 "highlights": [{
26 "score": 0.6008684039115906,
27 "path": "title",
28 "texts": [{"value": "When a Stranger Calls Back", "type": "hit"}]}]}
29{
30 "title": "Carol Channing: Larger Than Life",
31 "score": 4.2650651931762695,
32 "highlights": [{
33 "score": 0.6154072880744934,
34 "path": "title",
35 "texts": [{"value": "Carol Channing: Larger Than Life", "type": "hit"}]}]}

Atlas Search 会返回这些结果,因为字符 ger 出现在标题的不同位置。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1Document{{title=Germany in Autumn, score=6.160550117492676, highlights=[Document{{score=0.9180012345314026, path=title, texts=[Document{{value=Germany in Autumn, type=hit}}]}}]}}
2Document{{title=Gertie the Dinosaur, score=6.160550117492676, highlights=[Document{{score=0.9227690100669861, path=title, texts=[Document{{value=Gertie the Dinosaur, type=hit}}]}}]}}
3Document{{title=Germany Pale Mother, score=6.160550117492676, highlights=[Document{{score=0.9227690100669861, path=title, texts=[Document{{value=Germany Pale Mother, type=hit}}]}}]}}
4Document{{title=Geronimo: An American Legend, score=6.096138954162598, highlights=[Document{{score=0.9430088996887207, path=title, texts=[Document{{value=Geronimo: An American, type=hit}}, Document{{value= Legend, type=text}}]}}]}}
5Document{{title=Geri's Game, score=5.900832176208496, highlights=[Document{{score=1.1180211305618286, path=title, texts=[Document{{value=Geri's Game, type=hit}}]}}]}}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的左侧。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1Document{{title=South Park: Bigger Longer & Uncut, score=4.770905017852783, highlights=[Document{{score=0.6177878975868225, path=title, texts=[Document{{value=South Park: Bigger Longer, type=hit}}, Document{{value= & Uncut, type=text}}]}}]}}
2Document{{title=Roger Dodger, score=4.584150791168213, highlights=[Document{{score=0.905626654624939, path=title, texts=[Document{{value=Roger Dodger, type=hit}}]}}]}}
3Document{{title=The Crazy Stranger, score=4.535715103149414, highlights=[Document{{score=0.9203977584838867, path=title, texts=[Document{{value=The Crazy Stranger, type=hit}}]}}]}}
4Document{{title=The Ring Finger, score=4.535715103149414, highlights=[Document{{score=0.9131305813789368, path=title, texts=[Document{{value=The Ring Finger, type=hit}}]}}]}}
5Document{{title=Shoot the Messenger, score=4.535715103149414, highlights=[Document{{score=0.9227690100669861, path=title, texts=[Document{{value=Shoot the Messenger, type=hit}}]}}]}}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的右侧。当突出显示的路径仅在突出显示的查询的 autocomplete 操作符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1Document{{title=South Park: Bigger Longer & Uncut, score=4.395573139190674, highlights=[Document{{score=0.38510727882385254, path=title, texts=[Document{{value=South Park: Bigger Longer & Uncut, type=hit}}]}}]}}
2Document{{title=Bigger Stronger Faster*, score=4.33078145980835, highlights=[Document{{score=0.5282801985740662, path=title, texts=[Document{{value=Bigger Stronger Faster, type=hit}}, Document{{value=*, type=text}}]}}]}}
3Document{{title=The Toxic Avenger Part II, score=4.2905426025390625, highlights=[Document{{score=0.5984020829200745, path=title, texts=[Document{{value=The Toxic Avenger Part II, type=hit}}]}}]}}
4Document{{title=Carol Channing: Larger Than Life, score=4.2905426025390625, highlights=[Document{{score=0.6154072880744934, path=title, texts=[Document{{value=Carol Channing: Larger Than Life, type=hit}}]}}]}}
5Document{{title=When a Stranger Calls Back, score=4.2905426025390625, highlights=[Document{{score=0.6008684039115906, path=title, texts=[Document{{value=When a Stranger Calls Back, type=hit}}]}}]}}

Atlas Search 会返回这些结果,因为字符 ger 出现在标题的不同位置。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1'{
2 "title":"Gertie the Dinosaur",
3 "score":6.0822906494140625,
4 "highlights":[{
5 "score":0.9227690100669861,
6 "path":"title",
7 "texts":[{"value":"Gertie the Dinosaur","type":"hit"}]}]}'
8'{
9 "title":"Germany Year Zero",
10 "score":6.0822906494140625,
11 "highlights":[{
12 "score":0.9180012345314026,
13 "path":"title",
14 "texts":[{"value":"Germany Year Zero","type":"hit"}]}]}'
15'{
16 "title":"Germany in Autumn",
17 "score":6.0822906494140625,
18 "highlights":[{
19 "score":0.9180012345314026,
20 "path":"title",
21 "texts":[{"value":"Germany in Autumn","type":"hit"}]}]}'
22'{
23 "title":"Germany Pale Mother",
24 "score":6.0822906494140625,
25 "highlights":[{
26 "score":0.9227690100669861,
27 "path":"title",
28 "texts":[{"value":"Germany Pale Mother","type":"hit"}]}]}'
29'{
30 "title":"Gerhard Richter - Painting",
31 "score":6.0822906494140625,
32 "highlights":[{
33 "score":0.9386774897575378,
34 "path":"title",
35 "texts":[{"value":"Gerhard Richter - Painting","type":"hit"}]}]}'

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的左侧。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1'{
2 "title":"South Park: Bigger Longer & Uncut",
3 "score":4.7550506591796875,
4 "highlights":[{
5 "score":0.6177878975868225,
6 "path":"title",
7 "texts":[{"value":"South Park: Bigger Longer","type":"hit"},{"value":" & Uncut","type":"text"}]}]}'
8'{
9 "title":"Roger Dodger",
10 "score":4.568849563598633,
11 "highlights":[{
12 "score":0.905626654624939,
13 "path":"title",
14 "texts":[{"value":"Roger Dodger","type":"hit"}]}]}'
15'{
16 "title":"The Jazz Singer",
17 "score":4.520683288574219,
18 "highlights":[{
19 "score":0.9131305813789368,
20 "path":"title",
21 "texts":[{"value":"The Jazz Singer","type":"hit"}]}]}'
22'{
23 "title":"Love and Anger",
24 "score":4.520683288574219,
25 "highlights":[{
26 "score":0.9106559753417969,
27 "path":"title",
28 "texts":[{"value":"Love and Anger","type":"hit"}]}]}'
29'{
30 "title":"Save the Tiger",
31 "score":4.520683288574219,
32 "highlights":[{
33 "score":0.9106559753417969,
34 "path":"title",
35 "texts":[{"value":"Save the Tiger","type":"hit"}]}]}'

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的右侧。当突出显示的路径仅在突出显示的查询的 autocomplete 操作符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1'{
2 "title":"South Park: Bigger Longer & Uncut",
3 "score":4.371164321899414,
4 "highlights":[{
5 "score":0.38510727882385254,
6 "path":"title",
7 "texts":[{"value":"South Park: Bigger Longer & Uncut","type":"hit"}]}]}'
8'{
9 "title":"Bigger Stronger Faster*",
10 "score":4.3067307472229,
11 "highlights":[{
12 "score":0.5282801985740662,
13 "path":"title",
14 "texts":[{"value":"Bigger Stronger Faster","type":"hit"},{"value":"*","type":"text"}]}]}'
15'{
16 "title":"The Toxic Avenger Part II",
17 "score":4.26673698425293,
18 "highlights":[{
19 "score":0.5984020829200745,
20 "path":"title",
21 "texts":[{"value":"The Toxic Avenger Part II","type":"hit"}]}]}'
22'{
23 "title":"When a Stranger Calls Back",
24 "score":4.26673698425293,
25 "highlights":[{
26 "score":0.6008684039115906,
27 "path":"title",
28 "texts":[{"value":"When a Stranger Calls Back","type":"hit"}]}]}'
29'{
30 "title":"Carol Channing: Larger Than Life",
31 "score":4.26673698425293,
32 "highlights":[{
33 "score":0.6154072880744934,
34 "path":"title",
35 "texts":[{"value":"Carol Channing: Larger Than Life","type":"hit"}]}]}'

Atlas Search 会返回这些结果,因为字符 ger 出现在标题的不同位置。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 'highlights': [{
3 'path': 'title',
4 'score': 0.9227690100669861,
5 'texts': [{'type': 'hit', 'value': 'Gertie the Dinosaur'}]}],
6 'score': 6.085907459259033,
7 'title': 'Gertie the Dinosaur'}
8{
9 'highlights': [{
10 'path': 'title',
11 'score': 0.9180012345314026,
12 'texts': [{'type': 'hit', 'value': 'Germany Year Zero'}]}],
13 'score': 6.085907459259033,
14 'title': 'Germany Year Zero'}
15{
16 'highlights': [{
17 'path': 'title',
18 'score': 0.9180012345314026,
19 'texts': [{'type': 'hit', 'value': 'Germany in Autumn'}]}],
20 'score': 6.085907459259033,
21 'title': 'Germany in Autumn'}
22{
23 'highlights': [{
24 'path': 'title',
25 'score': 0.9227690100669861,
26 'texts': [{'type': 'hit', 'value': 'Germany Pale Mother'}]}],
27 'score': 6.085907459259033,
28 'title': 'Germany Pale Mother'}
29{
30 'highlights': [{
31 'path': 'title',
32 'score': 0.9386774897575378,
33 'texts': [{'type': 'hit', 'value': 'Gerhard Richter - Painting'}]}],
34 'score': 6.085907459259033,
35 'title': 'Gerhard Richter - Painting'}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的左侧。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 'highlights': [{
3 'path': 'title',
4 'score': 0.6177878975868225,
5 'texts': [{'type': 'hit', 'value': 'South Park: Bigger Longer'}, {'type': 'text', 'value': ' & Uncut'}]}],
6 'score': 4.807340621948242,
7 'title': 'South Park: Bigger Longer & Uncut'}
8{
9 'highlights': [{
10 'path': 'title',
11 'score': 0.905626654624939,
12 'texts': [{'type': 'hit', 'value': 'Roger Dodger'}]}],
13 'score': 4.6073713302612305,
14 'title': 'Roger Dodger'}
15{
16 'highlights': [{
17 'path': 'title',
18 'score': 0.9131305813789368,
19 'texts': [{'type': 'hit', 'value': 'The Jazz Singer'}]}],
20 'score': 4.577486038208008,
21 'title': 'The Jazz Singer'}
22{
23 'highlights': [{
24 'path': 'title',
25 'score': 0.9106559753417969,
26 'texts': [{'type': 'hit', 'value': 'Love and Anger'}]}],
27 'score': 4.577486038208008,
28 'title': 'Love and Anger'}
29{
30 'highlights': [{
31 'path': 'title',
32 'score': 0.9106559753417969,
33 'texts': [{'type': 'hit', 'value': 'Save the Tiger'}]}],
34 'score': 4.577486038208008,
35 'title': 'Save the Tiger'}

Atlas Search 会返回这些结果,因为字符 ger 出现在所有标题中单词的右侧。当突出显示的路径仅在突出显示的查询的 autocomplete 操作符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

1{
2 'highlights': [{
3 'path': 'title',
4 'score': 0.38510727882385254,
5 'texts': [{'type': 'hit', 'value': 'South Park: Bigger Longer & Uncut'}]}],
6 'score': 4.365298748016357,
7 'title': 'South Park: Bigger Longer & Uncut'}
8{
9 'highlights': [{
10 'path': 'title',
11 'score': 0.5282801985740662,
12 'texts':[{'type': 'hit', 'value': 'Bigger Stronger Faster'}, {'type': 'text', 'value': '*'}]}],
13 'score': 4.300583839416504,
14 'title': 'Bigger Stronger Faster*'}
15{
16 'highlights': [{
17 'path': 'title',
18 'score': 0.5984020829200745,
19 'texts': [{'type': 'hit', 'value': 'The Toxic Avenger Part II'}]}],
20 'score': 4.2650651931762695,
21 'title': 'The Toxic Avenger Part II'}
22{
23 'highlights': [{
24 'path': 'title',
25 'score': 0.6008684039115906,
26 'texts': [{'type': 'hit', 'value': 'When a Stranger Calls Back'}]}],
27 'score': 4.2650651931762695,
28 'title': 'When a Stranger Calls Back'}
29{
30 'highlights': [{
31 'path': 'title',
32 'score': 0.6154072880744934,
33 'texts': [{'type': 'hit', 'value': 'Carol Channing: Larger Than Life'}]}],
34 'score': 4.2650651931762695,
35 'title': 'Carol Channing: Larger Than Life'}

Atlas Search 会返回这些结果,因为字符 ger 出现在标题的不同位置。当突出显示的路径仅在突出显示的查询的 autocomplete 运算符中引用时,Atlas Search 会更粗略地将突出显示的 hit 与您的查询术语进行匹配。

下面的查询使用复合操作符在 movies 集合的 titleplot 字段中搜索以字符串 inter 开头的单词。

将以下查询复制并粘贴到 Query Editor 中,然后点击 Query Editor 中的 Search 按钮。

[
{
$search: {
compound: {
should: [
{
autocomplete: {
query: "inter",
path: "title"
}
},
{
autocomplete: {
query: "inter",
path: "plot"
}
}
],
minimumShouldMatch: 1
}
}
}
]

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段排除 titleplot 以外的所有字段。

1db.movies.aggregate([
2 {
3 $search: {
4 "compound": {
5 "should": [
6 {
7 "autocomplete": {
8 "query": "inter",
9 "path": "title",
10 },
11 },
12 {
13 "autocomplete": {
14 "query": "inter",
15 "path": "plot"
16 }
17 }
18 ],
19 "minimumShouldMatch": 1
20 },
21 },
22 },
23 {
24 $limit: 10,
25 },
26 {
27 $project:
28 {
29 "_id": 0,
30 "title": 1,
31 "plot": 1
32 },
33 },
34])

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段排除 titleplot 以外的所有字段。

movies 集合的 Aggregations 标签页中,从下拉菜单中选择阶段并为该阶段添加查询,以配置以下每个管道阶段。单击 Add Stage 添加其他阶段。

管道阶段
查询

$search

{
"compound": {
"should": [{
"autocomplete": {
"query": "inter",
"path": "title"
}
},
{
"autocomplete": {
"query": "inter",
"path": "plot"
}
}],
"minimumShouldMatch": 1
}
}

$limit

10

$project

{
"_id": 0,
"title": 1,
"plot": 1
}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段排除 titleplot 以外的所有字段。

1using MongoDB.Bson;
2using MongoDB.Bson.Serialization.Attributes;
3using MongoDB.Bson.Serialization.Conventions;
4using MongoDB.Driver;
5using MongoDB.Driver.Search;
6
7public class AutocompleteCompoundExample
8{
9 private const string MongoConnectionString = "<connection-string>";
10
11 public static void Main(string[] args)
12 {
13 // allow automapping of the camelCase database fields to our MovieDocument
14 var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
15 ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
16
17 // connect to your Atlas cluster
18 var mongoClient = new MongoClient(MongoConnectionString);
19 var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
20 var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
21
22 // define and run pipeline
23 var results = moviesCollection.Aggregate()
24 .Search(Builders<MovieDocument>.Search.Compound()
25 .Should(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Title, "inter"))
26 .Should(Builders<MovieDocument>.Search.Autocomplete(movie => movie.Plot, "inter")))
27 .Project<MovieDocument>(Builders<MovieDocument>.Projection
28 .Include(movie => movie.Plot)
29 .Include(movie => movie.Title)
30 .Exclude(movie => movie.Id))
31 .Limit(10)
32 .ToList();
33
34 // print results
35 foreach (var movie in results)
36 {
37 Console.WriteLine(movie.ToJson());
38 }
39 }
40}
41
42[BsonIgnoreExtraElements]
43public class MovieDocument
44{
45 [BsonIgnoreIfDefault]
46 public ObjectId Id { get; set; }
47 public string Plot { get; set; }
48 public string Title { get; set; }
49}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段排除 titleplot 以外的所有字段。

1package main
2
3import (
4 "context"
5 "fmt"
6
7 "go.mongodb.org/mongo-driver/v2/bson"
8 "go.mongodb.org/mongo-driver/v2/mongo"
9 "go.mongodb.org/mongo-driver/v2/mongo/options"
10)
11
12func main() {
13 // connect to your Atlas cluster
14 client, err := mongo.Connect(options.Client().ApplyURI("<connection-string>"))
15 if err != nil {
16 panic(err)
17 }
18 defer client.Disconnect(context.TODO())
19
20 // set namespace
21 collection := client.Database("sample_mflix").Collection("movies")
22
23 // define pipeline stages
24 searchStage := bson.D{
25 {Key: "$search", Value: bson.D{
26 {Key: "compound", Value: bson.D{
27 {Key: "should", Value: bson.A{
28 bson.D{
29 {Key: "autocomplete", Value: bson.D{{Key: "query", Value: "inter"}, {Key: "path", Value: "title"}}},
30 },
31 bson.D{
32 {Key: "autocomplete", Value: bson.D{{Key: "query", Value: "inter"}, {Key: "path", Value: "plot"}}},
33 },
34 }},
35 {Key: "minimumShouldMatch", Value: 1},
36 }},
37 }},
38 }
39 limitStage := bson.D{{Key: "$limit", Value: 10}}
40 projectStage := bson.D{{Key: "$project", Value: bson.D{{Key: "title", Value: 1}, {Key: "plot", Value: 1}, {Key: "_id", Value: 0}}}}
41 // run pipeline
42 cursor, err := collection.Aggregate(context.TODO(), mongo.Pipeline{searchStage, limitStage, projectStage})
43 if err != nil {
44 panic(err)
45 }
46
47 // print results
48 var results []bson.D
49 if err = cursor.All(context.TODO(), &results); err != nil {
50 panic(err)
51 }
52 for _, result := range results {
53 fmt.Println(result)
54 }
55}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段排除 titleplot 以外的所有字段。

1import static com.mongodb.client.model.Aggregates.limit;
2import static com.mongodb.client.model.Aggregates.project;
3import static com.mongodb.client.model.Projections.excludeId;
4import static com.mongodb.client.model.Projections.fields;
5import static com.mongodb.client.model.Projections.include;
6import com.mongodb.client.MongoClient;
7import com.mongodb.client.MongoClients;
8import com.mongodb.client.MongoCollection;
9import com.mongodb.client.MongoDatabase;
10import org.bson.Document;
11import java.util.Arrays;
12
13public class AutocompleteQuery {
14
15 public static void main(String[] args) {
16 // connect to your Atlas cluster
17 String uri = "<connection-string>";
18
19 try (MongoClient mongoClient = MongoClients.create(uri)) {
20 // set namespace
21 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
22 MongoCollection<Document> collection = database.getCollection("movies");
23
24 // define pipeline
25 Document agg = new Document(new Document("should", Arrays.asList(new Document("autocomplete",
26 new Document("path", "title")
27 .append("query", "inter")),
28 new Document("autocomplete",
29 new Document("path", "plot")
30 .append("query", "inter"))))
31 .append("minimumShouldMatch", 1L));
32
33 // run pipeline and print results
34 collection.aggregate(Arrays.asList(
35 eq("$search", eq("compound", agg)),
36 limit(10),
37 project(fields(excludeId(), include("title"))))).forEach(doc -> System.out.println(doc.toJson()));
38 }
39 }
40}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段排除 titleplot 以外的所有字段。

1import com.mongodb.client.model.Aggregates.limit
2import com.mongodb.client.model.Aggregates.project
3import com.mongodb.client.model.Filters.eq
4import com.mongodb.client.model.Projections.*
5import com.mongodb.kotlin.client.coroutine.MongoClient
6import kotlinx.coroutines.runBlocking
7import org.bson.Document
8
9fun main() {
10 val uri = "<connection-string>"
11 val mongoClient = MongoClient.create(uri)
12 val database = mongoClient.getDatabase("sample_mflix")
13 val collection = database.getCollection<Document>("movies")
14
15 runBlocking {
16 val agg = Document(
17 Document(
18 "should", listOf(
19 Document(
20 "autocomplete",
21 Document("path", "title")
22 .append("query", "inter")
23 ),
24 Document(
25 "autocomplete",
26 Document("path", "plot")
27 .append("query", "inter")
28 )
29 )
30 ).append("minimumShouldMatch", 1L)
31 )
32
33 val resultsFlow = collection.aggregate<Document>(
34 listOf(
35 eq("\$search", eq("compound", agg)),
36 limit(10),
37 project(fields(excludeId(), include("title", "plot")))
38 )
39 )
40 resultsFlow.collect { println(it) }
41 }
42 mongoClient.close()
43}

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段排除 titleplot 以外的所有字段。

1const { MongoClient } = require("mongodb");
2
3// connect to your Atlas cluster
4const uri =
5 "<connection-string>";
6
7const client = new MongoClient(uri);
8
9async function run() {
10 try {
11 await client.connect();
12
13 // set namespace
14 const database = client.db("sample_mflix");
15 const coll = database.collection("movies");
16
17 // define pipeline
18 const agg = [
19 {
20 '$search': {
21 'compound': {
22 'should': [
23 {
24 'autocomplete': {
25 'query': 'inter',
26 'path': 'title'
27 }
28 },
29 {
30 'autocomplete': {
31 'query': 'inter',
32 'path': 'plot'
33 }
34 }
35 ],
36 'minimumShouldMatch': 1
37 }
38 }
39 },
40 {
41 '$limit': 10
42 },
43 {
44 '$project': {
45 '_id': 0,
46 'title': 1,
47 'plot': 1
48 }
49 }
50 ];
51 // run pipelines
52 const result = await coll.aggregate(agg);
53
54 // print results
55 await result.forEach((doc) => console.log(doc));
56 } finally {
57 await client.close();
58 }
59}
60run().catch(console.dir);

查询包括:

  • $limit 阶段用于将输出限制为 10 个结果。

  • $project 阶段排除 titleplot 以外的所有字段。

1import pymongo
2
3# connect to your Atlas cluster
4client = pymongo.MongoClient('<connection-string>')
5
6# define pipeline
7pipeline = [
8 {
9 '$search': {
10 'compound': {
11 'should': [
12 {
13 'autocomplete': {
14 'query': 'inter',
15 'path': 'title'
16 }
17 }, {
18 'autocomplete': {
19 'query': 'inter',
20 'path': 'plot'
21 }
22 }
23 ],
24 'minimumShouldMatch': 1
25 }
26 }
27 },
28 {
29 '$limit': 10
30 },
31 {
32 '$project': {
33 '_id': 0, 'title': 1, 'plot': 1
34 }
35 }
36]
37# run pipeline
38result = client["sample_mflix"]["movies"].aggregate(pipeline)
39
40# print results
41for i in result:
42 print(i)

注意

结果可能会有所不同

Atlas Search 根据自动完成类型的索引定义中配置的分词策略返回不同的结果。要了解更多信息,请参阅如何为自动完成的字段编制索引。

SCORE: 8.931777000427246 _id: "573a13b8f29313caabd4bcbf"
plot: "A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men."
genres: Array
awards: Object
...
title: "Brief Interviews with Hideous Men"
SCORE: 8.2173433303833 _id: "573a13bcf29313caabd56968"
plot: "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring."
genres: Array
awards: Object
...
title: "The International"
SCORE: 8.182762145996094 _id: "573a13aaf29313caabd22bcf"
plot: "A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence."
genres: Array
awards: Object
...
title: "Intermission"
SCORE: 8.182762145996094 _id: "573a1398f29313caabceb7a6"
plot: "A hospital nurse becomes an
imdb: Object
awards: Object
...
title: "Interdevochka"
SCORE: 8.178873062133789 _id: "573a13b5f29313caabd452c6"
plot: "After falling out with his editor, a fading political journalist is forced to interview America's most popular soap actress."
genres: Array
awards: Object
...
title: "Interview"
SCORE: 8.158283233642578 _id: "573a1398f29313caabcea77a"
plot: "Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ..."
imdb: Object
awards: Object
...
title: "Intervista"
SCORE: 8.040483474731445 _id: "573a13aef29313caabd2c796"
plot: "Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot."
genres: Array
awards: Object
...
title: "The Interpreter"
SCORE: 8.02893352508545 _id: "573a13c3f29313caabd6b5c6"
plot: "Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan's bipolar ..."
genres: Array
awards: Object
...
title: "Boy Interrupted"
SCORE: 8.026378631591797 _id: "573a13d9f29313caabda8982"
plot: "Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment."
genres: Array
awards: Object
...
title: "The Internship"
SCORE: 8.01746654510498 _id: "573a13e2f29313caabdbdc4d"
plot: "Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show \"Skylark Tonight.\" When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission."
genres: Array
awards: Object
...
title: "The Interview"
SCORE: 10.543484687805176 _id: "573a13a0f29313caabd02f47"
plot: "Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ..."
genres: Array
awards: Object
...
title: "The First Snow of Winter"
SCORE: 10.543484687805176 _id: "573a13d2f29313caabd91d33"
plot: "As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier."
genres: Array
awards: Object
...
title: "Captain America: The Winter Soldier"
SCORE: 10.413713455200195 _id: "573a13daf29313caabdac230"
plot: "During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it's a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another."
genres: Array
awards: Object
...
title: "First Winter"
SCORE: 9.885751724243164 _id: "573a13d5f29313caabd9a45b"
plot: "WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ..."
genres: Array
awards: Object
...
title: "After Fall, Winter"
SCORE: 9.770956039428711 _id: "573a13bdf29313caabd5a0f4"
plot: "Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror."
genres: Array
awards: Object
...
title: "Splinter"
SCORE: 9.532302856445312 _id: "573a13dcf29313caabdb19c7"
plot: "Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining..."
genres: Array
awards: Object
...
title: "Winter of Discontent"
SCORE: 5.959532737731934 _id: "573a13c0f29313caabd62f21"
plot: "A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy."
genres: Array
awards: Object
...
title: "Suddenly, Last Winter"
SCORE: 5.959532737731934 _id: "573a13b1f29313caabd35dc7"
plot: "After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy."
genres: Array
awards: Object
...
title: "Kissed by Winter"
SCORE: 5.897221565246582 _id: "573a139af29313caabcf1762"
plot: "A mysterious creature is killing a farmer's livestock."
genres: Array
awards: Object
...
title: "In the Winter Dark"
SCORE: 5.897221565246582 _id: "573a1399f29313caabcecfef"
plot: "Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ..."
genres: Array
awards: Object
...
title: "A Tale of Winter"
SCORE: 8.727951049804688 _id: "573a13b8f29313caabd4bcbf"
plot: "A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men."
genres: Array
awards: Object
...
title: "Brief Interviews with Hideous Men"
SCORE: 8.719245910644531 _id: "573a139ff29313caabd01cc6"
plot: "On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ..."
genres: Array
awards: Object
...
title: "Sarah, Plain and Tall: Winter's End"
SCORE: 8.694562911987305 _id: "573a13d2f29313caabd91d33"
plot: "As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier."
imdb: Object
awards: Object
...
title: "Captain America: The Winter Soldier"
SCORE: 8.581620216369629 _id: "573a13dcf29313caabdb19c7"
plot: "Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining..."
genres: Array
awards: Object
...
title: "Winter of Discontent"
SCORE: 8.506681442260742 _id: "573a13a0f29313caabd02f47"
plot: "Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ..."
genres: Array
awards: Object
...
title: "The First Snow of Winter"
SCORE: 8.378528594970703 _id: "573a13d5f29313caabd9a45b"
plot: "WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ..."
genres: Array
awards: Object
...
title: "After Fall, Winter"
SCORE: 8.373418807983398 _id: "573a13bcf29313caabd56968"
plot: "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring."
genres: Array
awards: Object
...
title: "The International"
SCORE: 8.300098419189453 _id: "573a13aef29313caabd2c796"
plot: "Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot."
genres: Array
awards: Object
...
title: "The Interpreter"
SCORE: 8.299515724182129 _id: "573a139af29313caabcf0190"
plot: "Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ..."
genres: Array
awards: Object
...
title: "Mrs. Winterbourne"
SCORE: 8.299029350280762 _id: "573a13d9f29313caabda8982"
plot: "Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment."
genres: Array
awards: Object
...
title: "The Internship"

Search Tester 可能不会显示其所返回文档的所有字段。要查看所有字段,包括在查询路径中指定的字段,请展开结果中的文档。

1[
2 {
3 plot: 'A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.',
4 title: 'Brief Interviews with Hideous Men'
5 },
6 {
7 plot: "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
8 title: 'The International'
9 },
10 {
11 plot: 'A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence.',
12 title: 'Intermission'
13 },
14 {
15 plot: 'A hospital nurse becomes an "international girl", a prostitute who caters to foreigners with hard currency.',
16 title: 'Interdevochka'
17 },
18 {
19 plot: "After falling out with his editor, a fading political journalist is forced to interview America's most popular soap actress.",
20 title: 'Interview'
21 },
22 {
23 plot: 'Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ...',
24 title: 'Intervista'
25 },
26 {
27 plot: 'Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.',
28 title: 'The Interpreter'
29 },
30 {
31 plot: "Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan's bipolar ...",
32 title: 'Boy Interrupted'
33 },
34 {
35 plot: 'Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.',
36 title: 'The Internship'
37 },
38 {
39 plot: 'Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show "Skylark Tonight." When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission.',
40 title: 'The Interview'
41 }
42]

在这些结果中,字符 inter 出现在 titleplot 字段中某个词的开头。Atlas Search 返回以指定查询字符串开头的结果,因为 Atlas Search 会将查询词与其为从单词左侧开始的 titleplot 字段创建的词元进行匹配。

1[
2 {
3 plot: 'Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...',
4 title: 'The First Snow of Winter'
5 },
6 {
7 plot: 'As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.',
8 title: 'Captain America: The Winter Soldier'
9 },
10 {
11 plot: "During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it's a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another.",
12 title: 'First Winter'
13 },
14 {
15 plot: 'WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...',
16 title: 'After Fall, Winter'
17 },
18 {
19 plot: 'Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror.',
20 title: 'Splinter'
21 },
22 {
23 plot: 'Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...',
24 title: 'Winter of Discontent'
25 },
26 {
27 plot: 'A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy.',
28 title: 'Suddenly, Last Winter'
29 },
30 {
31 plot: 'After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy.',
32 title: 'Kissed by Winter'
33 },
34 {
35 plot: "A mysterious creature is killing a farmer's livestock.",
36 title: 'In the Winter Dark'
37 },
38 {
39 plot: 'Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ...',
40 title: 'A Tale of Winter'
41 }
42]

在这些结果中,字符 inter 出现在 titleplot 字段中单词的末尾。Atlas Search 返回以指定查询字符串结尾的结果,因为 Atlas Search 会将查询词与其为从单词右侧开始的 titleplot 字段创建的词元进行匹配,这些词元由分析器分隔。

1[
2 {
3 plot: 'A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.',
4 title: 'Brief Interviews with Hideous Men'
5 },
6 {
7 plot: 'On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ...',
8 title: "Sarah, Plain and Tall: Winter's End"
9 },
10 {
11 plot: 'As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.',
12 title: 'Captain America: The Winter Soldier'
13 },
14 {
15 plot: 'Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...',
16 title: 'Winter of Discontent'
17 },
18 {
19 plot: 'Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...',
20 title: 'The First Snow of Winter'
21 },
22 {
23 plot: 'WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...',
24 title: 'After Fall, Winter'
25 },
26 {
27 plot: "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
28 title: 'The International'
29 },
30 {
31 plot: 'Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.',
32 title: 'The Interpreter'
33 },
34 {
35 plot: 'Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ...',
36 title: 'Mrs. Winterbourne'
37 },
38 {
39 plot: 'Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.',
40 title: 'The Internship'
41 }
42]

在这些结果中,字符 inter 出现在 titleplot 字段中的某个单词中。Atlas Search 返回包含指定查询字符串的单词的结果,因为 Atlas Search 会将查询词与其为 titleplot 字段创建的长度介于 3 到 7 个字符之间的标记进行匹配。

1[
2 {
3 plot: 'A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.',
4 title: 'Brief Interviews with Hideous Men'
5 },
6 {
7 plot: "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
8 title: 'The International'
9 },
10 {
11 plot: 'A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence.',
12 title: 'Intermission'
13 },
14 {
15 plot: 'A hospital nurse becomes an "international girl", a prostitute who caters to foreigners with hard currency.',
16 title: 'Interdevochka'
17 },
18 {
19 plot: "After falling out with his editor, a fading political journalist is forced to interview America's most popular soap actress.",
20 title: 'Interview'
21 },
22 {
23 plot: 'Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ...',
24 title: 'Intervista'
25 },
26 {
27 plot: 'Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.',
28 title: 'The Interpreter'
29 },
30 {
31 plot: "Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan's bipolar ...",
32 title: 'Boy Interrupted'
33 },
34 {
35 plot: 'Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.',
36 title: 'The Internship'
37 },
38 {
39 plot: 'Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show "Skylark Tonight." When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission.',
40 title: 'The Interview'
41 }
42]

在这些结果中,字符 inter 出现在 titleplot 字段中某个词的开头。Atlas Search 返回以指定查询字符串开头的结果,因为 Atlas Search 会将查询词与其为从单词左侧开始的 titleplot 字段创建的词元进行匹配。

1[
2 {
3 plot: 'Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...',
4 title: 'The First Snow of Winter'
5 },
6 {
7 plot: 'As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.',
8 title: 'Captain America: The Winter Soldier'
9 },
10 {
11 plot: "During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it's a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another.",
12 title: 'First Winter'
13 },
14 {
15 plot: 'WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...',
16 title: 'After Fall, Winter'
17 },
18 {
19 plot: 'Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror.',
20 title: 'Splinter'
21 },
22 {
23 plot: 'Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...',
24 title: 'Winter of Discontent'
25 },
26 {
27 plot: 'A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy.',
28 title: 'Suddenly, Last Winter'
29 },
30 {
31 plot: 'After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy.',
32 title: 'Kissed by Winter'
33 },
34 {
35 plot: "A mysterious creature is killing a farmer's livestock.",
36 title: 'In the Winter Dark'
37 },
38 {
39 plot: 'Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ...',
40 title: 'A Tale of Winter'
41 }
42]

在这些结果中,字符 inter 出现在 titleplot 字段中单词的末尾。Atlas Search 返回以指定查询字符串结尾的结果,因为 Atlas Search 会将查询词与其为从单词右侧开始的 titleplot 字段创建的词元进行匹配,这些词元由分析器分隔。

1[
2 {
3 plot: 'A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.',
4 title: 'Brief Interviews with Hideous Men'
5 },
6 {
7 plot: 'On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ...',
8 title: "Sarah, Plain and Tall: Winter's End"
9 },
10 {
11 plot: 'As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.',
12 title: 'Captain America: The Winter Soldier'
13 },
14 {
15 plot: 'Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...',
16 title: 'Winter of Discontent'
17 },
18 {
19 plot: 'Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...',
20 title: 'The First Snow of Winter'
21 },
22 {
23 plot: 'WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...',
24 title: 'After Fall, Winter'
25 },
26 {
27 plot: "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
28 title: 'The International'
29 },
30 {
31 plot: 'Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.',
32 title: 'The Interpreter'
33 },
34 {
35 plot: 'Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ...',
36 title: 'Mrs. Winterbourne'
37 },
38 {
39 plot: 'Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.',
40 title: 'The Internship'
41 }
42]

在这些结果中,字符 inter 出现在 titleplot 字段中的某个单词中。Atlas Search 返回包含指定查询字符串的单词的结果,因为 Atlas Search 会将查询词与其为 titleplot 字段创建的长度介于 3 到 7 个字符之间的标记进行匹配。

1{
2 "plot" : 'A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.',
3 "title" : 'Brief Interviews with Hideous Men'
4}
5{
6 "plot" : 'An Interpol agent attempts to expose a high-profile financial institution\'s role in an international arms dealing ring.',
7 "title" : 'The International'
8}
9{
10 "plot" : 'A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence.',
11 "title" : 'Intermission'
12}
13{
14 "plot" : 'A hospital nurse becomes an "international girl", a prostitute who caters to foreigners with hard currency.',
15 "title" : 'Interdevochka'
16}
17{
18 "plot" : 'After falling out with his editor, a fading political journalist is forced to interview America\'s most popular soap actress.',
19 "title" : 'Interview'
20}
21{
22 "plot" : 'Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ...',
23 "title" : 'Intervista'
24}
25{
26 "plot" : 'Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.',
27 "title" : 'The Interpreter'
28}
29{
30 "plot" : 'Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan\'s bipolar ...',
31 "title" : 'Boy Interrupted'
32}
33{
34 "plot" : 'Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.',
35 "title" : 'The Internship'
36}
37{
38 "plot" : 'Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show "Skylark Tonight." When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission.',
39 "title" : 'The Interview'
40}

在这些结果中,字符 inter 出现在 titleplot 字段中某个词的开头。Atlas Search 返回以指定查询字符串开头的结果,因为 Atlas Search 会将查询词与其为从单词左侧开始的 titleplot 字段创建的词元进行匹配。

1{
2 "plot" : 'Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...',
3 "title" : 'The First Snow of Winter'
4}
5{
6 "plot" : 'As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.',
7 "title" : 'Captain America: The Winter Soldier'
8}
9{
10 "plot" : 'During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it\'s a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another.',
11 "title" : 'First Winter'
12}
13{
14 "plot" : 'WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...',
15 "title" : 'After Fall, Winter'
16}
17{
18 "plot" : 'Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror.',
19 "title" : 'Splinter'
20}
21{
22 "plot" : 'Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...',
23 "title" : 'Winter of Discontent'
24}
25{
26 "plot" : 'A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy.',
27 "title" : 'Suddenly, Last Winter'
28}
29{
30 "plot" : 'After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy.',
31 "title" : 'Kissed by Winter'
32}
33{
34 "plot" : 'A mysterious creature is killing a farmer\'s livestock.',
35 "title" : 'In the Winter Dark'
36}
37{
38 "plot" : 'Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ...',
39 "title" : 'A Tale of Winter'
40}

在这些结果中,字符 inter 出现在 titleplot 字段中单词的末尾。Atlas Search 返回以指定查询字符串结尾的结果,因为 Atlas Search 会将查询词与其为从单词右侧开始的 titleplot 字段创建的词元进行匹配,这些词元由分析器分隔。

1{
2 "plot" : 'A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.',
3 "title" : 'Brief Interviews with Hideous Men'
4}
5{
6 "plot" : 'On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ...',
7 "title" : 'Sarah, Plain and Tall: Winter\'s End'
8}
9{
10 "plot" : 'As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.',
11 "title" : 'Captain America: The Winter Soldier'
12}
13{
14 "plot" : 'Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...',
15 "title" : 'Winter of Discontent'
16}
17{
18 "plot" : 'Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...',
19 "title" : 'The First Snow of Winter'
20}
21{
22 "plot" : 'WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...',
23 "title" : 'After Fall, Winter'
24}
25{
26 "plot" : 'An Interpol agent attempts to expose a high-profile financial institution\'s role in an international arms dealing ring.',
27 "title" : 'The International'
28}
29{
30 "plot" : 'Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.',
31 "title" : 'The Interpreter'
32}
33{
34 "plot" : 'Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ...',
35 "title" : 'Mrs. Winterbourne'
36}
37{
38 "plot" : 'Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.',
39 "title" : 'The Internship'
40}

在这些结果中,字符 inter 出现在 titleplot 字段中的某个单词中。Atlas Search 返回包含指定查询字符串的单词的结果,因为 Atlas Search 会将查询词与其为 titleplot 字段创建的长度介于 3 到 7 个字符之间的标记进行匹配。

1[
2 {plot A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.}
3 {title Brief Interviews with Hideous Men}
4]
5[
6 {plot An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.}
7 {title The International}
8]
9[
10 {plot A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence.}
11 {title Intermission}
12]
13[
14 {plot A hospital nurse becomes an "international girl", a prostitute who caters to foreigners with hard currency.}
15 {title Interdevochka}
16]
17[
18 {plot After falling out with his editor, a fading political journalist is forced to interview America's most popular soap actress.}
19 {title Interview}
20]
21[
22 {plot Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ...}
23 {title Intervista}
24]
25[
26 {plot Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.}
27 {title The Interpreter}
28]
29[
30 {plot Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan's bipolar ...}
31 {title Boy Interrupted}
32]
33[
34 {plot Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.}
35 {title The Internship}
36]
37[
38 {plot Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show "Skylark Tonight." When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission.}
39 {title The Interview}
40]

在这些结果中,字符 inter 出现在 titleplot 字段中某个词的开头。Atlas Search 返回以指定查询字符串开头的结果,因为 Atlas Search 会将查询词与其为从单词左侧开始的 titleplot 字段创建的词元进行匹配。

1[
2 {plot Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...}
3 {title The First Snow of Winter}
4]
5[
6 {plot As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.}
7 {title Captain America: The Winter Soldier}
8]
9[
10 {plot During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it's a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another.}
11 {title First Winter}
12]
13[
14 {plot WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...}
15 {title After Fall, Winter}
16]
17[
18 {plot Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror.}
19 {title Splinter}
20]
21[
22 {plot Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...}
23 {title Winter of Discontent}
24]
25[
26 {plot A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy.}
27 {title Suddenly, Last Winter}
28]
29[
30 {plot After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy.}
31 {title Kissed by Winter}
32]
33[
34 {plot A mysterious creature is killing a farmer's livestock.}
35 {title In the Winter Dark}
36]
37[
38 {plot Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ...}
39 {title A Tale of Winter}
40]

在这些结果中,字符 inter 出现在 titleplot 字段中单词的末尾。Atlas Search 返回以指定查询字符串结尾的结果,因为 Atlas Search 会将查询词与其为从单词右侧开始的 titleplot 字段创建的词元进行匹配,这些词元由分析器分隔。

1[
2 {plot A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.}
3 {title Brief Interviews with Hideous Men}
4]
5[
6 {plot On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ...}
7 {title Sarah, Plain and Tall: Winter's End}
8]
9[
10 {plot As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.}
11 {title Captain America: The Winter Soldier}
12]
13[
14 {plot Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...}
15 {title Winter of Discontent}
16]
17[
18 {plot Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...}
19 {title The First Snow of Winter}
20]
21[
22 {plot WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...}
23 {title After Fall, Winter}
24]
25[
26 {plot An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.}
27 {title The International}
28]
29[
30 {plot Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.}
31 {title The Interpreter}
32]
33[
34 {plot Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ...}
35 {title Mrs. Winterbourne}
36]
37[
38 {plot Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.}
39 {title The Internship}
40]

在这些结果中,字符 inter 出现在 titleplot 字段中的某个单词中。Atlas Search 返回包含指定查询字符串的单词的结果,因为 Atlas Search 会将查询词与其为 titleplot 字段创建的长度介于 3 到 7 个字符之间的标记进行匹配。

1{
2 "plot" : "A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.",
3 "title" : "Brief Interviews with Hideous Men"
4}
5{
6 "plot" : "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
7 "title" : "The International"
8}
9{
10 "plot" : "A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence.",
11 "title" : "Intermission"
12}
13{
14 "plot" : "A hospital nurse becomes an \"international girl\", a prostitute who caters to foreigners with hard currency.",
15 "title" : "Interdevochka"
16}
17{
18 "plot" : "After falling out with his editor, a fading political journalist is forced to interview America's most popular soap actress.",
19 "title" : "Interview"
20}
21{
22 "plot" : "Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ...",
23 "title" : "Intervista"
24}
25{
26 "plot" : "Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.",
27 "title" : "The Interpreter"
28}
29{
30 "plot" : "Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan's bipolar ...",
31 "title" : "Boy Interrupted"
32}
33{
34 "plot" : "Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.",
35 "title" : "The Internship"
36}
37{
38 "plot" : "Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show \"Skylark Tonight.\" When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission.",
39 "title" : "The Interview"
40}

在这些结果中,字符 inter 出现在 titleplot 字段中某个词的开头。Atlas Search 返回以指定查询字符串开头的结果,因为 Atlas Search 会将查询词与其为从单词左侧开始的 titleplot 字段创建的词元进行匹配。

1{
2 "plot" : 'Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...',
3 "title" : 'The First Snow of Winter'
4}
5{
6 "plot" : 'As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.',
7 "title" : 'Captain America: The Winter Soldier'
8}
9{
10 "plot" : 'During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it\'s a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another.',
11 "title" : 'First Winter'
12}
13{
14 "plot" : 'WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...',
15 "title" : 'After Fall, Winter'
16}
17{
18 "plot" : 'Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror.',
19 "title" : 'Splinter'
20}
21{
22 "plot" : 'Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...',
23 "title" : 'Winter of Discontent'
24}
25{
26 "plot" : 'A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy.',
27 "title" : 'Suddenly, Last Winter'
28}
29{
30 "plot" : 'After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy.',
31 "title" : 'Kissed by Winter'
32}
33{
34 "plot" : 'A mysterious creature is killing a farmer\'s livestock.',
35 "title" : 'In the Winter Dark'
36}
37{
38 "plot" : 'Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ...',
39 "title" : 'A Tale of Winter'
40}

在这些结果中,字符 inter 出现在 titleplot 字段中单词的末尾。Atlas Search 返回以指定查询字符串结尾的结果,因为 Atlas Search 会将查询词与其为从单词右侧开始的 titleplot 字段创建的词元进行匹配,这些词元由分析器分隔。

1{
2 "plot": "A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.",
3 "title": "Brief Interviews with Hideous Men"
4}
5{
6 "plot": "On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ...",
7 "title": "Sarah, Plain and Tall\:\ Winter's End"
8}
9{
10 "plot": "As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history\:\ an assassin known as the Winter Soldier.",
11 "title": "Captain America\:\ The Winter Soldier"
12}
13{
14 "plot": "Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...",
15 "title": "Winter of Discontent"
16}
17{
18 "plot": "Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...",
19 "title": "The First Snow of Winter"
20}
21{
22 "plot": "WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...",
23 "title": "After Fall, Winter"
24}
25{
26 "plot": "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
27 "title": "The International"
28}
29{
30 "plot": "Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.",
31 "title": "The Interpreter"
32}
33{
34 "plot": "Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ...",
35 "title": "Mrs. Winterbourne"
36}
37{
38 "plot": "Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.",
39 "title": "The Internship"
40}

在这些结果中,字符 inter 出现在 titleplot 字段中的某个单词中。Atlas Search 返回包含指定查询字符串的单词的结果,因为 Atlas Search 会将查询词与其为 titleplot 字段创建的长度介于 3 到 7 个字符之间的标记进行匹配。

1Document{{plot=A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men., title=Brief Interviews with Hideous Men}}
2Document{{plot=An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring., title=The International}}
3Document{{plot=A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence., title=Intermission}}
4Document{{plot=A hospital nurse becomes an "international girl", a prostitute who caters to foreigners with hard currency., title=Interdevochka}}
5Document{{plot=After falling out with his editor, a fading political journalist is forced to interview America's most popular soap actress., title=Interview}}
6Document{{plot=Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ..., title=Intervista}}
7Document{{plot=Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot., title=The Interpreter}}
8Document{{plot=Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan's bipolar ..., title=Boy Interrupted}}
9Document{{plot=Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment., title=The Internship}}
10Document{{plot=Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show "Skylark Tonight." When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission., title=The Interview}}

在这些结果中,字符 inter 出现在 titleplot 字段中某个词的开头。Atlas Search 返回以指定查询字符串开头的结果,因为 Atlas Search 会将查询词与其为从单词左侧开始的 titleplot 字段创建的词元进行匹配。

1Document{{plot=Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ..., title=The First Snow of Winter}}
2Document{{plot=As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier., title=Captain America: The Winter Soldier}}
3Document{{plot=During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it's a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another., title=First Winter}}
4Document{{plot=WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ..., title=After Fall, Winter}}
5Document{{plot=Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror., title=Splinter}}
6Document{{plot=Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining..., title=Winter of Discontent}}
7Document{{plot=A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy., title=Suddenly, Last Winter}}
8Document{{plot=After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy., title=Kissed by Winter}}
9Document{{plot=A mysterious creature is killing a farmer's livestock., title=In the Winter Dark}}
10Document{{plot=Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ..., title=A Tale of Winter}}

在这些结果中,字符 inter 出现在 titleplot 字段中单词的末尾。Atlas Search 返回以指定查询字符串结尾的结果,因为 Atlas Search 会将查询词与其为从单词右侧开始的 titleplot 字段创建的词元进行匹配,这些词元由分析器分隔。

1Document{{plot=A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men., title=Brief Interviews with Hideous Men}}
2Document{{plot=On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ..., title=Sarah, Plain and Tall: Winter's End}}
3Document{{plot=As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier., title=Captain America: The Winter Soldier}}
4Document{{plot=Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining..., title=Winter of Discontent}}
5Document{{plot=Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ..., title=The First Snow of Winter}}
6Document{{plot=WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ..., title=After Fall, Winter}}
7Document{{plot=An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring., title=The International}}
8Document{{plot=Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot., title=The Interpreter}}
9Document{{plot=Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ..., title=Mrs. Winterbourne}}
10Document{{plot=Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment., title=The Internship}}

在这些结果中,字符 inter 出现在 titleplot 字段中的某个单词中。Atlas Search 返回包含指定查询字符串的单词的结果,因为 Atlas Search 会将查询词与其为 titleplot 字段创建的长度介于 3 到 7 个字符之间的标记进行匹配。

1{
2 "plot": "A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.",
3 "title": "Brief Interviews with Hideous Men"
4}
5{
6 "plot": "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
7 "title": "The International"
8}
9{
10 "plot": "A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence.",
11 "title": "Intermission"
12}
13{
14 "plot": "A hospital nurse becomes an \"international girl\", a prostitute who caters to foreigners with hard currency.",
15 "title": "Interdevochka"
16}
17{
18 "plot": "After falling out with his editor, a fading political journalist is forced to interview America's most popular soap actress.",
19 "title": "Interview"
20}
21{
22 "plot": "Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ...",
23 "title": "Intervista"
24}
25{
26 "plot": "Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.",
27 "title": "The Interpreter"
28}
29{
30 "plot": "Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan's bipolar ...",
31 "title": "Boy Interrupted"
32}
33{
34 "plot": "Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.",
35 "title": "The Internship"
36}
37{
38 "plot": "Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show \"Skylark Tonight.\" When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission.",
39 "title": "The Interview"
40}

在这些结果中,字符 inter 出现在 titleplot 字段中某个词的开头。Atlas Search 返回以指定查询字符串开头的结果,因为 Atlas Search 会将查询词与其为从单词左侧开始的 titleplot 字段创建的词元进行匹配。

1{
2 "plot": "Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...",
3 "title": "The First Snow of Winter"
4}
5{
6 "plot": "As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.",
7 "title": "Captain America: The Winter Soldier"
8}
9{
10 "plot": "During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it's a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another.",
11 "title": "First Winter"
12}
13{
14 "plot": "WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...",
15 "title": "After Fall, Winter"
16}
17{
18 "plot": "Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror.",
19 "title": "Splinter"
20}
21{
22 "plot": "Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...",
23 "title": "Winter of Discontent"
24}
25{
26 "plot": "A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy.",
27 "title": "Suddenly, Last Winter"
28}
29{
30 "plot": "After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy.",
31 "title": "Kissed by Winter"
32}
33{
34 "plot": "A mysterious creature is killing a farmer's livestock.",
35 "title": "In the Winter Dark"
36}
37{
38 "plot": "Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ...",
39 "title": "A Tale of Winter"
40}

在这些结果中,字符 inter 出现在 titleplot 字段中单词的末尾。Atlas Search 返回以指定查询字符串结尾的结果,因为 Atlas Search 会将查询词与其为从单词右侧开始的 titleplot 字段创建的词元进行匹配,这些词元由分析器分隔。

1{
2 "plot": "A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.",
3 "title": "Brief Interviews with Hideous Men"
4}
5{
6 "plot": "On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ...",
7 "title": "Sarah, Plain and Tall: Winter's End"
8}
9{
10 "plot": "As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.",
11 "title": "Captain America: The Winter Soldier"
12}
13{
14 "plot": "Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...",
15 "title": "Winter of Discontent"
16}
17{
18 "plot": "Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...",
19 "title": "The First Snow of Winter"
20}
21{
22 "plot": "WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...",
23 "title": "After Fall, Winter"
24}
25{
26 "plot": "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
27 "title": "The International"
28}
29{
30 "plot": "Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.",
31 "title": "The Interpreter"
32}
33{
34 "plot": "Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ...",
35 "title": "Mrs. Winterbourne"
36}
37{
38 "plot": "Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.",
39 "title": "The Internship"
40}

在这些结果中,字符 inter 出现在 titleplot 字段中的某个单词中。Atlas Search 返回包含指定查询字符串的单词的结果,因为 Atlas Search 会将查询词与其为 titleplot 字段创建的长度介于 3 到 7 个字符之间的标记进行匹配。

1{
2 "plot": "A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.",
3 "title": "Brief Interviews with Hideous Men"
4}
5{
6 "plot": "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
7 "title": "The International"
8}
9{
10 "plot": "A variety of losers in Dublin have harrowingly farcical intersecting stories of love, greed and violence.",
11 "title": "Intermission"
12}
13{
14 "plot": "A hospital nurse becomes an \"international girl\", a prostitute who caters to foreigners with hard currency.",
15 "title": "Interdevochka"
16}
17{
18 "plot": "After falling out with his editor, a fading political journalist is forced to interview America's most popular soap actress.",
19 "title": "Interview"
20}
21{
22 "plot": "Cinecitta, the huge movie studio outside Rome, is 50 years old and Fellini is interviewed by a Japanese TV crew about the films he has made there over the years as he begins production on ...",
23 "title": "Intervista"
24}
25{
26 "plot": "Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.",
27 "title": "The Interpreter"
28}
29{
30 "plot": "Boy Interrupted looks at the life of Evan Perry a 15-year-old boy from New York who committed suicide in 2005. The film made by his parents Dana and Hart examines how Evan's bipolar ...",
31 "title": "Boy Interrupted"
32}
33{
34 "plot": "Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.",
35 "title": "The Internship"
36}
37{
38 "plot": "Dave Skylark and producer Aaron Rapoport run the celebrity tabloid show \"Skylark Tonight.\" When they land an interview with a surprise fan, North Korean dictator Kim Jong-un, they are recruited by the CIA to turn their trip to Pyongyang into an assassination mission.",
39 "title": "The Interview"
40}

在这些结果中,字符 inter 出现在 titleplot 字段中某个词的开头。Atlas Search 返回以指定查询字符串开头的结果,因为 Atlas Search 会将查询词与其为从单词左侧开始的 titleplot 字段创建的词元进行匹配。

1{
2 "plot": "Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...",
3 "title": "The First Snow of Winter"
4}
5{
6 "plot": "As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.",
7 "title": "Captain America: The Winter Soldier"
8}
9{
10 "plot": "During a winter of record-breaking cold; an apocalyptic blackout strands a group of Brooklynites in a remote farmhouse. At first it's a party of sex; drugs; and yoga. But as supplies dwindle; they turn against one another.",
11 "title": "First Winter"
12}
13{
14 "plot": "WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...",
15 "title": "After Fall, Winter"
16}
17{
18 "plot": "Trapped in an isolated gas station by a voracious Splinter parasite that transforms its still living victims into deadly hosts, a young couple and an escaped convict must find a way to work together to survive this primal terror.",
19 "title": "Splinter"
20}
21{
22 "plot": "Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...",
23 "title": "Winter of Discontent"
24}
25{
26 "plot": "A couple engage in discussions with people on the street, politicians and religious leaders about the discrimination against gays and lesbians in Italy.",
27 "title": "Suddenly, Last Winter"
28}
29{
30 "plot": "After her son is hospitalized, a doctor cheats on her husband with a snow plow driver who is a suspect in her investigation of the recent death of a young Arab boy.",
31 "title": "Kissed by Winter"
32}
33{
34 "plot": "A mysterious creature is killing a farmer's livestock.",
35 "title": "In the Winter Dark"
36}
37{
38 "plot": "Felicie and Charles have a serious if whirlwind holiday romance. Due to a mix-up on addresses they lose contact, and five years later at Christmas-time Felicie is living with her mother in ...",
39 "title": "A Tale of Winter"
40}

在这些结果中,字符 inter 出现在 titleplot 字段中单词的末尾。Atlas Search 返回以指定查询字符串结尾的结果,因为 Atlas Search 会将查询词与其为从单词右侧开始的 titleplot 字段创建的词元进行匹配,这些词元由分析器分隔。

1{
2 "plot": "A graduate student (Nicholson) copes with a recent breakup by conducting interviews with various men.",
3 "title": "Brief Interviews with Hideous Men"
4}
5{
6 "plot": "On a cold winter day a mysterious stranger shows up at the Witting Farm. He is John Witting, the father of Jacob Witting who abandoned Jacob and his mother when Jacob was little. Jacob is ...",
7 "title": "Sarah, Plain and Tall: Winter's End"
8}
9{
10 "plot": "As Steve Rogers struggles to embrace his role in the modern world, he teams up with another super soldier, the black widow, to battle a new threat from old history: an assassin known as the Winter Soldier.",
11 "title": "Captain America: The Winter Soldier"
12}
13{
14 "plot": "Set against the momentous backdrop of the whirlwind Tahrir Square protests, Winter of discontent poetically explores the anguish of a victim state terror in 2009, presaging and intertwining...",
15 "title": "Winter of Discontent"
16}
17{
18 "plot": "Sean is a little duck with a big problem. Due to a mishap with a jet aircraft Sean misses the annual migration South and has to face the winter alone. However, he is befriended by a water ...",
19 "title": "The First Snow of Winter"
20}
21{
22 "plot": "WINTER is a dangerous, sexy, poignant and at times darkly funny story about two people who desperately want intimacy but have fashioned lives of reclusivity and emotional fracture which ...",
23 "title": "After Fall, Winter"
24}
25{
26 "plot": "An Interpol agent attempts to expose a high-profile financial institution's role in an international arms dealing ring.",
27 "title": "The International"
28}
29{
30 "plot": "Political intrigue and deception unfold inside the United Nations, where a U.S. Secret Service agent is assigned to investigate an interpreter who overhears an assassination plot.",
31 "title": "The Interpreter"
32}
33{
34 "plot": "Connie Doyle is eighteen and pregnant when her boyfriend kicks her out. She accidentally ends up on a train where she meets Hugh Winterbourne and his wife Patricia who is pregnant. The ...",
35 "title": "Mrs. Winterbourne"
36}
37{
38 "plot": "Two salesmen whose careers have been torpedoed by the digital age find their way into a coveted internship at Google, where they must compete with a group of young, tech-savvy geniuses for a shot at employment.",
39 "title": "The Internship"
40}

在这些结果中,字符 inter 出现在 titleplot 字段中的某个单词中。Atlas Search 返回包含指定查询字符串的单词的结果,因为 Atlas Search 会将查询词与其为 titleplot 字段创建的长度介于 3 到 7 个字符之间的标记进行匹配。

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

将以下查询复制并粘贴到 Query Editor 中,然后点击 Query Editor 中的 Search 按钮。

[
{
"$searchMeta": {
"facet": {
"operator": {
"autocomplete": {
"query": "Gravity",
"path": "title"
}
},
"facets": {
"titleFacet": {
"type": "string",
"path": "title"
}
}
}
}
}
]

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

1db.movies.aggregate([{
2 $searchMeta: {
3 "facet": {
4 "operator": {
5 "autocomplete": {
6 "query": "Gravity",
7 "path": "title"
8 }
9 },
10 "facets": {
11 "titleFacet": {
12 "type": "string",
13 "path": "title"
14 }
15 }
16 }
17 }
18}])

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

movies 集合的 Aggregations 标签页中,从下拉菜单中选择阶段并为该阶段添加查询,以配置以下管道阶段。

管道阶段
查询

$searchMeta

{
facet: {
operator: {
autocomplete: {
path: 'title',
query: 'Gravity'
}
},
facets: {
titleFacet: {
type: 'string',
path: 'title'
}
}
}
}

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

1using MongoDB.Bson;
2using MongoDB.Bson.Serialization.Attributes;
3using MongoDB.Bson.Serialization.Conventions;
4using MongoDB.Driver;
5using MongoDB.Driver.Search;
6
7public class AutocompleteFacetExample
8{
9 private const string MongoConnectionString = "<connection-string>";
10
11 public static void Main(string[] args)
12 {
13 // allow automapping of the camelCase database fields to our MovieDocument
14 var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
15 ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
16
17 // connect to your Atlas cluster
18 var mongoClient = new MongoClient(MongoConnectionString);
19 var mflixDatabase = mongoClient.GetDatabase("sample_mflix");
20 var moviesCollection = mflixDatabase.GetCollection<MovieDocument>("movies");
21
22 // define and run pipeline
23 var results = moviesCollection.Aggregate()
24 .SearchMeta(Builders<MovieDocument>.Search.Facet(
25 Builders<MovieDocument>.Search.Autocomplete(movie => movie.Title, "Gravity"),
26 Builders<MovieDocument>.SearchFacet.String("titleFacet", movie => movie.Title, 100)))
27 .Single();
28
29 // print results
30 Console.WriteLine(results.ToJson());
31 }
32}
33
34[BsonIgnoreExtraElements]
35public class MovieDocument
36{
37 [BsonIgnoreIfDefault]
38 public ObjectId Id { get; set; }
39 public string Title { get; set; }
40}

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

1package main
2
3import (
4 "context"
5 "fmt"
6
7 "go.mongodb.org/mongo-driver/v2/bson"
8 "go.mongodb.org/mongo-driver/v2/mongo"
9 "go.mongodb.org/mongo-driver/v2/mongo/options"
10)
11
12func main() {
13 // connect to your Atlas cluster
14 client, err := mongo.Connect(options.Client().ApplyURI("<connection-string>"))
15 if err != nil {
16 panic(err)
17 }
18 defer client.Disconnect(context.TODO())
19
20 // set namespace
21 collection := client.Database("sample_mflix").Collection("movies")
22
23 // define pipeline stages
24 searchMetaStage := bson.D{{Key: "$searchMeta", Value: bson.M{
25 "facet": bson.M{
26 "operator": bson.M{
27 "autocomplete": bson.M{
28 "path": "title", "query": "Gravity",
29 },
30 },
31 "facets": bson.M{
32 "titleFacet": bson.M{
33 "path": "title", "type": "string",
34 },
35 },
36 },
37 }}}
38
39 // run pipeline
40 cursor, err := collection.Aggregate(context.TODO(), mongo.Pipeline{searchMetaStage})
41 if err != nil {
42 panic(err)
43 }
44
45 // print results
46 var results []bson.D
47 if err = cursor.All(context.TODO(), &results); err != nil {
48 panic(err)
49 }
50 for _, result := range results {
51 fmt.Println(result)
52 }
53}

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoDatabase;
5import org.bson.Document;
6
7import java.util.Arrays;
8
9public class FacetAutocompleteExample {
10 public static void main(String[] args) {
11 // connect to your Atlas cluster
12 String uri = "<connection-string>";
13
14 try (MongoClient mongoClient = MongoClients.create(uri)) {
15 // set namespace
16 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
17 MongoCollection<Document> collection = database.getCollection("movies");
18
19 // define pipeline
20 Document agg = new Document("$searchMeta", new Document("facet",
21 new Document("operator",
22 new Document("autocomplete",
23 new Document("path", "title")
24 .append("query", "Gravity")))
25 .append("facets",
26 new Document("titleFacet",
27 new Document("type", "string").append("path", "title"))
28 )));
29 // run pipeline and print results
30 collection.aggregate(Arrays.asList(agg))
31 .forEach(doc -> System.out.println(doc.toJson()));
32
33 }
34 }
35}

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

1import com.mongodb.client.model.Aggregates.limit
2import com.mongodb.client.model.Aggregates.project
3import com.mongodb.client.model.Filters.eq
4import com.mongodb.client.model.Projections.*
5import com.mongodb.kotlin.client.coroutine.MongoClient
6import kotlinx.coroutines.runBlocking
7import org.bson.Document
8
9fun main() {
10 val uri = "<connection-string>"
11 val mongoClient = MongoClient.create(uri)
12 val database = mongoClient.getDatabase("sample_mflix")
13 val collection = database.getCollection<Document>("movies")
14
15 runBlocking {
16 val agg = Document(
17 "\$searchMeta", Document(
18 "facet",
19 Document(
20 "operator",
21 Document(
22 "autocomplete",
23 Document("path", "title")
24 .append("query", "Gravity")
25 )
26 )
27 .append(
28 "facets",
29 Document(
30 "titleFacet",
31 Document("type", "string").append("path", "title")
32 )
33 )
34 )
35 )
36
37 val resultsFlow = collection.aggregate<Document>(listOf(agg))
38 resultsFlow.collect { println(it) }
39 }
40 mongoClient.close()
41}

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

1const { MongoClient } = require("mongodb");
2
3// connect to your Atlas cluster
4const uri =
5 "<connection-string>";
6
7const client = new MongoClient(uri);
8
9async function run() {
10 try {
11 await client.connect();
12
13 // set namespace
14 const database = client.db("sample_mflix");
15 const coll = database.collection("movies");
16
17 // define pipeline
18 const agg = [{$searchMeta: {facet: {
19 operator: {
20 autocomplete: {path: "title", query: "Gravity"}
21 },
22 facets: {
23 titleFacet: {type: "string", path: "title"}
24 }}}}];
25 // run pipeline
26 const result = coll.aggregate(agg);
27
28 // print results
29 await result.forEach((doc) => console.dir(JSON.stringify(doc)));
30 } finally {
31 await client.close();
32 }
33}
34run().catch(console.dir);

以下查询使用 $searchMeta 阶段返回在 movies 集合的 title 字段中包含 Gravity 一词的电影的唯一值。此查询的索引定义限制了从 stringFacet 索引返回的结果,其中 autocompletestringFacet 类型都位于 title 字段上。

1import pymongo
2
3# connect to your Atlas cluster
4client = pymongo.MongoClient('<connection-string>')
5
6# define pipeline
7pipeline = [{"$searchMeta": {
8 "facet": {
9 "operator": {
10 "autocomplete": {"path": "title", "query": "Gravity"}
11 },
12 "facets": {
13 "titleFacet": {"type": "string", "path": "title"}
14 }}}}]
15# run pipeline
16result = client["sample_mflix"]["movies"].aggregate(pipeline)
17
18# print results
19for i in result:
20 print(i)
count: Object
lowerBound: 5
facet: Object
titleFacet: Object
buckets: Array (3)
0: Object
_id: "Gravity"
count: 3
1: Object
_id: "Defying Gravity"
count: 1
2: Object
_id: "Laws of Gravity"
count: 1

Search Tester 可能不会显示其所返回文档的所有字段。要查看所有字段,包括在查询路径中指定的字段,请展开结果中的文档。

1[{
2 count: { lowerBound: Long("5") },
3 facet: {
4 titleFacet: {
5 buckets: [
6 { _id: 'Gravity', count: Long("3") },
7 { _id: 'Defying Gravity', count: Long("1") },
8 { _id: 'Laws of Gravity', count: Long("1") }
9 ]
10 }
11 }
12}]
1[{
2 count: { lowerBound: Long("5") },
3 facet: {
4 titleFacet: {
5 buckets: [
6 { _id: 'Gravity', count: Long("3") },
7 { _id: 'Defying Gravity', count: Long("1") },
8 { _id: 'Laws of Gravity', count: Long("1") }
9 ]
10 }
11 }
12}]
1{
2 "count" : {
3 "lowerBound" : NumberLong(5),
4 "total" : null
5 },
6 "facet" : {
7 "titleFacet" : {
8 "buckets" : [
9 {
10 "_id" : "Gravity",
11 "count" : NumberLong(3)
12 },
13 {
14 "_id" : "Defying Gravity",
15 "count" : NumberLong(1)
16 },
17 {
18 "_id" : "Laws of Gravity",
19 "count" : NumberLong(1)
20 }]
21 }
22 }
23}
1[
2 {
3 count [{
4 lowerBound 5}
5 ]
6 }
7 {
8 facet [{
9 titleFacet [{
10 buckets [
11 [{_id Gravity} {count 3}]
12 [{_id Defying Gravity} {count 1}]
13 [{_id Laws of Gravity} {count 1}]
14 ]
15 }]}]
16 }
17]
1{
2 "count": {
3 "lowerBound": 5
4 },
5 "facet": {
6 "titleFacet": {
7 "buckets": [
8 {
9 "_id": "Gravity",
10 "count": 3
11 },
12 {
13 "_id": "Defying Gravity",
14 "count": 1
15 },
16 {
17 "_id": "Laws of Gravity",
18 "count": 1
19 }]
20 }
21 }
22}
1Document{{count=Document{{lowerBound=5}},
2facet=Document{{titleFacet=Document{{buckets=[Document{{_id=Gravity,
3count=3}}, Document{{_id=Defying Gravity, count=1}}, Document{{_id=Laws
4of Gravity, count=1}}]}}}}}}
1'{
2 "count":{
3 "lowerBound":5
4 },
5 "facet":{
6 "titleFacet":{
7 "buckets":[
8 {
9 "_id":"Gravity",
10 "count":3
11 },
12 {
13 "_id":"Defying Gravity",
14 "count":1
15 },
16 {
17 "_id":"Laws of Gravity",
18 "count":1
19 }
20 ]
21 }
22 }
23 }'
1{
2 'count': {'lowerBound': 5},
3 'facet': {
4 'titleFacet': {
5 'buckets': [
6 {
7 '_id': 'Gravity',
8 'count': 3
9 },
10 {
11 '_id': 'Defying Gravity',
12 'count': 1
13 },
14 {
15 '_id': 'Laws of Gravity',
16 'count': 1
17 }]
18 }
19 }
20}

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

如果您想看到如下结果中显示的重复标题,请在不使用分面情况下运行前面的 autocomplete 操作符查询,并使用 $search 阶段。您还必须使用 $project 阶段排除 title 以外的所有字段。

[
{ title: 'Gravity' },
{ title: 'Gravity' },
{ title: 'Gravity' },
{ title: 'Defying Gravity' },
{ title: 'Laws of Gravity' }
]

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

如果您想看到如下结果中显示的重复标题,请在不使用分面情况下运行前面的 autocomplete 操作符查询,并使用 $search 阶段。您还必须使用 $project 阶段排除 title 以外的所有字段。

[
{ title: 'Gravity' },
{ title: 'Gravity' },
{ title: 'Gravity' },
{ title: 'Defying Gravity' },
{ title: 'Laws of Gravity' }
]

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

如果您想看到如下结果中显示的重复标题,请在不使用分面情况下运行前面的 autocomplete 操作符查询,并使用 $search 阶段。您还必须使用 $project 阶段排除 title 以外的所有字段。

{ "title" : "Gravity" }
{ "title" : "Gravity" }
{ "title" : "Gravity" }
{ "title" : "Defying Gravity" }
{ "title" : "Laws of Gravity" }

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

如果您想看到如下结果中显示的重复标题,请在不使用分面情况下运行前面的 autocomplete 操作符查询,并使用 $search 阶段。您还必须使用 $project 阶段排除 title 以外的所有字段。

[{title Gravity}],
[{title Gravity}],
[{title Gravity}],
[{title Defying Gravity}],
[{title Laws of Gravity}]

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

如果您想看到如下结果中显示的重复标题,请在不使用分面情况下运行前面的 autocomplete 操作符查询,并使用 $search 阶段。您还必须使用 $project 阶段排除 title 以外的所有字段。

{"title": "Gravity"}
{"title": "Gravity"}
{"title": "Gravity"}
{"title": "Defying Gravity"}
{"title": "Laws of Gravity"}

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

如果您想看到如下结果中显示的重复标题,请在不使用分面情况下运行前面的 autocomplete 操作符查询,并使用 $search 阶段。您还必须使用 $project 阶段排除 title 以外的所有字段。

Document{{title=Gravity}}
Document{{title=Gravity}}
Document{{title=Gravity}}
Document{{title=Defying Gravity}}
Document{{title=Laws of Gravity}}

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

如果您想看到如下结果中显示的重复标题,请在不使用分面情况下运行前面的 autocomplete 操作符查询,并使用 $search 阶段。您还必须使用 $project 阶段排除 title 以外的所有字段。

{ title: 'Gravity' }
{ title: 'Gravity' }
{ title: 'Gravity' }
{ title: 'Defying Gravity' }
{ title: 'Laws of Gravity' }

Atlas Search 返回在 title 字段中包含 Gravity 一词的文档。结果中的 count 字段指示集合中具有相同标题的文档数。在结果中,Atlas Search 从集合中找到了三个以 Gravity 为标题的文档,但是 Atlas Search 省略了重复的标题,仅返回了一个匹配的文档。

如果您想看到如下结果中显示的重复标题,请在不使用分面情况下运行前面的 autocomplete 操作符查询,并使用 $search 阶段。您还必须使用 $project 阶段排除 title 以外的所有字段。

{ 'title': 'Gravity' }
{ 'title': 'Gravity' }
{ 'title': 'Gravity' }
{ 'title': 'Defying Gravity' }
{ 'title': 'Laws of Gravity' }

要学习;了解更多信息,请参阅如何运行自动完成和部分匹配Atlas Search查询。

后退

运算符和收集器

在此页面上