我有一个包含上述字段的文档:
SELECT
o.OrderId,
o.[Action],
o.NumberOfItems,
vol.FirstAction,
vol.LastAction
FROM
dbo.Orders o
JOIN dbo.iv_OrdersLog_FirstLastXYZAction vol WITH (NOEXPAND)
ON o.OrderId = vol.Order_Id
WHERE
o.[Action] = 'XYZ';
我需要知道如何在字段上创建索引:“formatted_address”
哪个是子文档数组。所以我添加了这段代码:
{
"_id" : ObjectId("55545754754575775757"),
"ref" : 161,
"updatedAt" : ISODate("2017-07-06T17:37:23.786Z"),
"createdAt" : ISODate("2017-07-04T16:57:41.257Z"),
"place" : {
"html_attributions" : [],
"vicinity" : "Paris",
"utc_offset" : 120,
"url" : "https://maps.google.com/?q=Paris,+France&ftid=0x47e66e1f06e2b70f:0x40b82c3688c9460",
"types" : [
"locality",
"political"
],
"scope" : "GOOGLE",
"reference" : "CmRbAAAA_URStRniv8M-nCXl79L6zwf_DUcDwtt7L6DrY0_ZTf3Wkq4tmtZ7dYVod5dmzuwRfSCNWvZG8ey71D6ooNGgqoPadVCqf9tlNMIKe209blvIeAOE92wDZ_Oj-_uEv9i2EhDyXVuaeQQrVqWaNdY6jfcWGhRrdJvHfm_vQPpd-Hb7rBOMszo1xA",
"place_id" : "ChIJD7fiBh9u5kcRYJSMaMOCCwQ",
"name" : "Paris",
"id" : "691b237b0322f28988f3ce03e321ff72a12167fd",
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
"geometry" : {
"viewport" : {
"east" : 2.46992079999995,
"north" : 48.9021449,
"west" : 2.22519299999999,
"south" : 48.815573
},
"location" : {
"lng" : 2.35222190000002,
"lat" : 48.856614
}
},
"formatted_address" : "Paris, France",
"adr_address" : "<span class=\"locality\">Paris</span>, <span class=\"country-name\">France</span>",
"description" : "Le MacBook Pro doté de la révolutionnaire Touch Bar est disponible en modèles 13 et 15 pouces. ... Vérifier la disponibilité MacBook Pro 13 pouces - Gris sidéral ..... Les prix comprennent la TVA (20 %) et la taxe sur les primes d'assurance",
"prix" : 1.499,
"titre" : "macbook pro",
"premium_test" : false,
"premium" : {
"statut" : false
},
"etatProduit" : [
ObjectId("578372bf092521281c913af8")
],
"departement" : [],
"sous_categorie" : [
ObjectId("57aae8781149cd000751436c")
],
"user_id" : [
ObjectId("575fda6a485328b0194a0a8a")
],
"media_type" : [
ObjectId("57975f7b6b6f9224115ce691")
],
"media" : [
"file-1499187461324.png",
"file-1499187535058.jpg"
],
"pointure" : 0,
"capacite" : 0,
"piscine" : false,
"nombre_pieces" : 0
}
查询为:annonceSchema.index({ place :'text' });
感谢。