嵌套集合中的匹配对象名称全文搜索mongodb

时间:2014-03-06 07:05:40

标签: mongodb mongodb-java

我们在mongo db集合中有一个嵌套对象,例如profile对象具有地址和联系人数据的数组。

{
"_id" : "f714af57-b4bd-4c1d-b09c-88f71a446262",
"_class" : "com.vaap.dataobject.profilemanagement.CompanyTypeProfile",
"companyCode" : "IBM",
"companyShortName" : "IBM",
"companyTitle" : "IBM",
"companyName" : "IBM",
"companyDescription" : "IBM",
"parentCompanyId" : "",
"companyOwnerName" : "",
"companyPhoneNo" : "",
"companyEmail" : "",
"companyFaxNo" : "",
"companyWebsite" : "",
"companyTotalEmployees" : "",
"companyAnnualRevenue" : "",
"totalPayPeriods" : "",
"payPeriodStartDate" : "",
"companyCreditLimit" : "",
"companyCurrencyId" : "",
"addressData" : [ 
    {
        "_id" : "b418982e-4b7a-43c0-aeb6-1ed43ec12f9a",
        "addressTypeId" : "efa5d767-41cf-4fa6-b252-70f4113370ea",
        "addressTypeName" : "Business",
        "addressName" : "IBM, Tysons",
        "addressLine1" : "123 Main Street",
        "addressLine2" : "",
        "countryName" : "United States of America",
        "countryId" : "b7520372-6dd7-4d76-94a8-4a5eeee26408",
        "stateName" : "Virginia",
        "stateId" : "2b155b92-c2f5-44a3-90aa-c188eed38c13",
        "cityName" : "Fairfax",
        "cityId" : "ed8ae0f4-eff6-46fc-a214-89b3451407bd",
        "countyName" : "",
        "countyId" : "",
        "zipCode" : "20152",
        "zipPlusCode" : "",
        "ruralCode" : "",
        "duration" : "10"
    }
],
"contactsData" : [ 
    {
        "_id" : "c9389dbd-1b65-4c1a-a9a5-a3c33d89e3b6",
        "contactTypeName" : "Business",
        "contactTypeId" : "423571d5-5a3a-4f56-9aed-dbb1cef3d9ad",
        "prefix" : "Mr.",
        "firstName" : "Ravi",
        "middleName" : "V",
        "lastName" : "Pulipaka",
        "nickName" : "Ravi",
        "title" : "CEO",
        "priorName" : "Ravi",
        "primaryContactMethodId" : "ae69fea8-1d54-4b98-813b-0313b7571802",
        "primaryContactMethodName" : "Phone",
        "primaryPhone" : "703-777-7777",
        "primaryEmail" : "",
        "primaryFaxNo" : "",
        "secondaryFaxNo" : "",
        "secondaryPhone" : "",
        "businessPhone" : "",
        "homePhone" : "",
        "personalPhone" : "",
        "spousePhone" : "",
        "vacationPhone" : "",
        "secondaryEmail" : "",
        "businessEmail" : "",
        "homeEmail" : "",
        "personalEmail" : "",
        "spouseEmail" : "",
        "alternateEmail" : "",
        "vacationEmail" : "",
        "addressLine1" : "",
        "addressLine2" : "",
        "countryName" : "",
        "countryId" : "",
        "stateName" : "",
        "stateId" : "",
        "cityName" : "",
        "cityId" : "",
        "countyName" : "",
        "countyId" : "",
        "zipCode" : "",
        "zipPlusCode" : "",
        "ruralCode" : ""
    }
],
"projectsData" : [],
"recCreBy" : "Rakesh Kumar Goyal",
"recCreDate" : "03-Mar-2014",
"aspectSource" : "AE",
"aspectType" : "Customer",
"clientId" : "VAAP-CLIENT-1"

}

我们可以使用mongo db全文搜索来搜索个人资料集合。但是返回结果没有任何信息可以返回与集合中的哪个字段完全匹配的记录。有什么方法可以让我知道匹配字段或匹配嵌套对象(主要配置文件或联系人数据或地址数据)。

我正在搜索“Ravi”,并有兴趣知道“Ravi”是否与addressData或contactsData或个人资料本身匹配。

0 个答案:

没有答案