[SERVER-11652] unique index bug Created: 10/Nov/13  Updated: 10/Nov/13  Resolved: 10/Nov/13

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.4.6, 2.4.7, 2.4.8
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: zuoan Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

test code ===>

    public static void testIndex() throws UnknownHostException {
        MongoClient  mgoLocal   = new MongoClient("");
        DBCollection collection = mgoLocal.getDB("test_index").getCollection("url");
 
        // create unique index
        DBObject indexFileds = new BasicDBObject();
        indexFileds.put("url", 1);
        collection.ensureIndex(indexFileds, "url_1", true);
 
        // insert document
        String str = "http://www.biomedcentral.com/bmcgeriatr/search/results?drpAddedInLast=&txtSearch4=&txtSearch3=&txtSearch2=bmc+geriatrics&txtSearch1=dementia%2C+or+alzheimer&drpToDate=&drpOrderBy=by+date&drpFromDate=&page=8&jou_id=2009&itemsPerPage=25&portal_id=&excludePhrase1=&excludeField1=&search-button=Search&drpField1=&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&journalAbbreviation=bmcgeriatr&drpField3=%5BAU%5D&drpField2=%5BTA%5D&drpPhrase4=&excludeSearchText1=&drpField4=&drpPhrase3=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&journalIssn=&drpPhrase2=exact&drpPhrase1=&articleType=&saveHistory=false";
        for (int i = 0; i < 10000; i++) {
            DBObject doc = new BasicDBObject();
            doc.put("url", str);
            collection.insert(doc);
        }
        
        // count
        System.out.println(collection.count());        // ==> 10000
        
        // query count
        DBObject query = new BasicDBObject();
        query.put("url", str);
        System.out.println(collection.count(query));   // ==> 0
    }



 Comments   
Comment by Scott Hernandez (Inactive) [ 10/Nov/13 ]

What you are describing is the current limitation for the size of an index value (key): http://docs.mongodb.org/manual/reference/limits/#Index%20Key

Soon this will cause an error so it is less confusing: SERVER-5290

You may also want to watch and/or vote on this one too: SERVER-3372

Generated at Thu Feb 08 03:26:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.