Lucene 查询结构化摘要
搜索命令的 解释响应包含与该命令执行的查询相关的信息。响应包括 Atlas Search 为满足 $search
查询而执行的 Lucene 查询的结构化详情。
此页面包含:
Atlas Search 操作符创建的一些 Lucene 查询
结构化摘要中包含的 Lucene 查询选项
每个 Lucene 查询类型的 Lucene 查询结构化摘要示例
注意
关于示例
BooleanQuery
以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "compound" : { 7 "must" : [ { 8 "compound" : { 9 "should" : [ { 10 "text" : { 11 "query" : "historic", 12 "path" : "summary" 13 } 14 }, 15 { 16 "text" : { 17 "query" : "Portugal", 18 "path" : "address.country" 19 } 20 }, 21 { 22 "text" : { 23 "query" : "railway", 24 "path" : "transit" 25 } 26 } ] 27 } 28 } ], 29 "mustNot" : [ { 30 "text" : { 31 "query" : "Apartment", 32 "path" : "property_type" 33 } 34 } ] 35 } 36 }, 37 "explain" : { 38 "type" : "BooleanQuery", 39 "args" : { 40 "must" : [ { 41 "path" : "compound.must", 42 "type" : "BooleanQuery", 43 "args" : { 44 "must" : [ ], 45 "mustNot" : [ ], 46 "should" : [ 47 { 48 "path" : "compound.must.compound.should[0]", 49 "type" : "TermQuery", 50 "args" : { 51 "path" : "summary", 52 "value" : "historic" 53 } 54 }, 55 { 56 "path" : "compound.must.compound.should[1]", 57 "type" : "TermQuery", 58 "args" : { 59 "path" : "address.country", 60 "value" : "portugal" 61 } 62 }, 63 { 64 "path" : "compound.must.compound.should[2]", 65 "type" : "TermQuery", 66 "args" : { 67 "path" : "transit", 68 "value" : "railway" 69 } 70 } 71 ], 72 "filter" : [ ], 73 "minimumShouldMatch" : 0 74 } 75 } ], 76 "mustNot" : [ { 77 "path" : "compound.mustNot", 78 "type" : "TermQuery", 79 "args" : { 80 "path" : "property_type", 81 "value" : "apartment" 82 } 83 } ], 84 "should" : [ ], 85 "filter" : [ ], 86 "minimumShouldMatch" : 0 87 } 88 } 89 }, 90 ... 91 }, 92 ... 93 ], 94 ... 95 }
ConstantScoreQuery
对于恒定得分查询,结构化摘要包括以下选项的详细信息:
字段类型必要性说明query
必需ConstantScoreQuery
的子项。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "equals" : { 7 "path" : "host.host_identity_verified", 8 "value" : true 9 } 10 }, 11 "explain" : { 12 "type" : "ConstantScoreQuery", 13 "args" : { 14 "query" : { 15 "type" : "TermQuery", 16 "args" : { 17 "path" : "host.host_identity_verified", 18 "value" : "T" 19 } 20 } 21 } 22 } 23 } 24 }, 25 { 26 "$_internalSearchIdLookup" : { } 27 } 28 ], 29 ... 30 }
FunctionScoreQuery
对于 Lucene
FunctionScoreQuery
查询,结构化摘要包含有关以下选项的详细信息:字段类型必要性说明scoreFunction
字符串必需查询中使用的评分表达式。query
必需查询。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "near" : { 7 "path" : "accomodates", 8 "origin" : 8, 9 "pivot" : 2 10 } 11 }, 12 "explain" : { 13 "type" : "BooleanQuery", 14 "args" : { 15 "must" : [ ], 16 "mustNot" : [ ], 17 "should" : [ 18 { 19 "type" : "BooleanQuery", 20 "args" : { 21 "must" : [ ], 22 "mustNot" : [ ], 23 "should" : [ 24 { 25 "type" : "FunctionScoreQuery", 26 "args" : { 27 "scoreFunction" : "expr(pivot / (pivot + abs(origin - value)))", 28 "query" : { 29 "type" : "LongDistanceFeatureQuery", 30 "args" : { }, 31 "stats" : { } 32 } 33 } 34 } 35 ], 36 "filter" : [ 37 { 38 "type" : "PointRangeQuery", 39 "args" : { 40 "path" : "accomodates", 41 "representation" : "double", 42 "gte" : 8.000000000000002, 43 "lte" : NaN 44 } 45 } 46 ], 47 "minimumShouldMatch" : 0 48 } 49 }, 50 { 51 "type" : "LongDistanceFeatureQuery", 52 "args" : { }, 53 "stats" : { } 54 } 55 ], 56 "filter" : [ ], 57 "minimumShouldMatch" : 0 58 } 59 } 60 }, 61 ... 62 }, 63 ... 64 ], 65 ... 66 }
LatLonPointDistanceQuery
对于 Lucene
LatLonPointDistanceQuery
查询,此响应仅包含解释时间故障。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "geoWithin" : { 7 "path" : "address.location", 8 "circle" : { 9 "radius" : 4800, 10 "center" : { 11 "type" : "Point", 12 "coordinates" : [ 13 -122.419472, 14 37.765302 15 ] 16 } 17 } 18 } 19 }, 20 "explain" : { 21 "type" : "LatLonPointDistanceQuery", 22 "args" : { } 23 } 24 } 25 }, 26 ... 27 ], 28 ... 29 }
LatLonShapeQuery
对于 Lucene
LatLonShapeQuery
查询,此响应仅包含解释时间故障。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "geoShape" : { 7 "path" : "address.location", 8 "relation" : "within", 9 "geometry" : { 10 "type" : "Polygon", 11 "coordinates" : [ 12 [ 13 [ -74.3994140625, 40.5305017757 ], 14 [ -74.7290039063, 40.5805846641 ], 15 [ -74.7729492188, 40.9467136651 ], 16 [ -74.0698242188, 41.1290213475 ], 17 [ -73.65234375, 40.9964840144 ], 18 [ -72.6416015625, 40.9467136651 ], 19 [ -72.3559570313, 40.7971774152 ], 20 [ -74.3994140625, 40.5305017757 ] 21 ] 22 ] 23 } 24 } 25 }, 26 "explain" : { 27 "type" : "LatLonShapeQuery", 28 "args" : { } 29 } 30 }, 31 ... 32 }, 33 ... 34 ], 35 ... 36 }
LongDistanceFeatureQuery
对于 Lucene
LongDistanceFeatureQuery
,响应仅包含解释时间故障。以下示例显示了针对
sample_mflix.movies
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "near" : { 7 "path" : "released", 8 "origin" : ISODate("1915-09-13T00:00:00Z"), 9 "pivot" : 7776000000 10 } 11 }, 12 "explain" : { 13 "type" : "LongDistanceFeatureQuery", 14 "args" : { } 15 } 16 }, 17 ... 18 }, 19 ... 20 ], 21 ... 22 }
MultiTermQueryConstantScoreWrapper
对于 Lucene
MultiTermQueryConstantScoreWrapper
查询,结构化摘要包含有关以下参数的详细信息:字段类型必要性说明queries
列表<解释响应>必需查询列表。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "regex" : { 7 "path" : "access", 8 "query" : "full(.{0,5})", 9 "allowAnalyzedField" : true 10 } 11 }, 12 "explain" : { 13 "type" : "MultiTermQueryConstantScoreWrapper", 14 "args" : { 15 "queries" : [ 16 { 17 "type" : "DefaultQuery", 18 "args" : { 19 "queryType" : "RegexpQuery" 20 } 21 } 22 ] 23 } 24 } 25 }, 26 ... 27 }, 28 ... 29 ], 30 ... 31 }
PhraseQuery
对于 Lucene
PhraseQuery
查询,结构化摘要包含有关以下参数的详细信息:字段类型必要性说明path
字符串必需要搜索的索引字段。query
字符串必需要搜索的一个或多个字符串。slop
int必需query
短语中单词之间允许的距离。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "phrase" : { 7 "path" : "description", 8 "query" : "comfortable apartment", 9 "slop" : 2 10 } 11 }, 12 "explain" : { 13 "type" : "PhraseQuery", 14 "args" : { 15 "path" : "description", 16 "query" : "[comfortable, apartment]", 17 "slop" : 2 18 } 19 } 20 }, 21 ... 22 }, 23 ... 24 ], 25 ... 26 }
PointRangeQuery
对于 Lucene
PointRangeQuery
查询,结构化摘要包含有关以下参数的详细信息:字段类型必要性说明path
字符串必需要搜索的索引字段。representation
字符串Optional数字表示形式。对日期类型数据的查询不包括表示形式。gte
数字Optional查询的下限。lte
数字Optional查询的上限。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "range" : { 7 "path" : "number_of_reviews", 8 "gt" : 5 9 } 10 }, 11 "explain" : { 12 "type" : "BooleanQuery", 13 "args" : { 14 "must" : [ ], 15 "mustNot" : [ ], 16 "should" : [ 17 { 18 "type" : "PointRangeQuery", 19 "args" : { 20 "path" : "number_of_reviews", 21 "representation" : "double", 22 "gte" : 5.000000000000001 23 } 24 }, 25 { 26 "type" : "PointRangeQuery", 27 "args" : { 28 "path" : "number_of_reviews", 29 "representation" : "int64", 30 "gte" : NumberLong(6) 31 } 32 } 33 ], 34 "filter" : [ ], 35 "minimumShouldMatch" : 0 36 } 37 } 38 }, 39 ... 40 }, 41 ... 42 ], 43 ... 44 }
TermQuery
对于术语查询,结构化摘要包括有关以下参数的详细信息:
字段类型必要性说明path
字符串必需要搜索的索引字段。value
字符串必需要搜索的字符串。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "queryString" : { 7 "defaultPath" : "summary", 8 "query" : "quiet" 9 } 10 }, 11 "explain" : { 12 "type" : "TermQuery", 13 "args" : { 14 "path" : "summary", 15 "value" : "quiet" 16 } 17 } 18 }, 19 ... 20 }, 21 ... 22 ], 23 ... 24 }
Default
未由其他 Lucene 查询显式定义的 Lucene 查询将使用默认查询进行序列化。结构化摘要包含有关以下选项的详细信息:
字段类型必要性说明queryType
字符串必需。Lucene 查询的类型。以下示例显示了针对
sample_airbnb.listingsAndReviews
集合运行的查询的explain
响应。1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "near" : { 7 "origin" : { 8 "type" : "Point", 9 "coordinates" : [ 10 -8.61308, 11 41.1413 12 ] 13 }, 14 "pivot" : 1000, 15 "path" : "address.location" 16 } 17 }, 18 "explain" : { 19 "type" : "DefaultQuery", 20 "args" : { 21 "queryType" : "LatLonPointDistanceFeatureQuery" 22 } 23 } 24 }, 25 ... 26 }, 27 ... 28 ], 29 ... 30 }