[SERVER-15727] two-dimension Array $elemMatch bug Created: 20/Oct/14  Updated: 10/Dec/14  Resolved: 29/Oct/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: rendong Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-13963 Different Results from nested array q... Closed
Related
related to SERVER-1264 $elemMatch on subArray Closed
Operating System: ALL
Steps To Reproduce:

db.foo.insert({x:[{a:[[1,2]], b:[[3,4]]}], y:[{a:[[5,6]], b:[[7,8]]}]})
db.foo.find({x:{$elemMatch:{a:{$elemMatch:{$in:[2]}}}}})

Participants:

 Description   

like this query

  
{
	"fieldsValue" : {
		  "$elemMatch" : {
 			"namePath" : {
				"$elemMatch" : {
					"$in" : ["some word"]
				}
			}
		}
	}
}

at 2.4.8 version can work ok,at 2.6.5 find nothing,not test other version



 Comments   
Comment by David Storch [ 29/Oct/14 ]

Hi rendong,

Thanks for helping us look into this by providing additional information about this issue. After review, we have identified this as expected behavior. The behavior change in matching of two-dimensional arrays was due to buggy behavior in 2.4.x versions that was fixed in 2.6.0. It is documented in the "Compatibility Changes" in the 2.6 Release Notes.

Furthermore, this ticket is a duplicate of SERVER-13963. Please refer to SERVER-13963 (in particular this comment) for a complete explanation of why this change was made.

I'm going to close this ticket as a duplicate, but feel free to reach out with any further questions or concerns.

Best,
Dave

Comment by rendong [ 28/Oct/14 ]

thank you for apply,you con insert this document into collection.

document

// Some comments here
{
  
    "1638f168-e3d8-4c0d-b7f4-e6f10ce47abc" : [
        {
            "namePath" : [
                [
                    "平装"
                ]
            ],
            "idPath" : [
                [
                    "2464"
                ]
            ]
        }
    ],
    "ef66e5bf-8a80-4b03-ae7c-7de19f576212" : [
        null
    ],
    "54eb75ac-85b6-4d43-aa9d-60246c60bd17" : [
        null
    ],
    "f18b456f-9879-403c-8d42-791dfc5b56b7" : [
        {
            "namePath" : [
                [
                    "绘画",
                    "美术学",
                    "艺术",
                    "高等教育"
                ]
            ],
            "idPath" : [
                [
                    "861",
                    "201",
                    "41",
                    "2547"
                ]
            ]
        }
    ],
    "7e8f3836-dea0-4a70-a1bd-b48b67d909ca" : [
        0
    ],
    "654c2783-b6f0-4629-80a8-ca8a365b0c08" : [
        "山水·花鸟临摹课教学(附辅学光盘)"
    ],
    "e2263056-7528-48d7-a9ce-ae3d02cec046" : [
        "21-10139-001"
    ],
    "019d4698-0709-4203-981d-216bfb5e0202" : [
        ""
    ],
    "e8ea9aee-1c15-4329-8415-ab17123cb64a" : [
        0
    ],
    "88207965-abde-46e6-8bf0-f2ec8b92b207" : [
        {
            "namePath" : [
                [
                    "16开"
                ]
            ],
            "idPath" : [
                [
                    "2466"
                ]
            ]
        }
    ],
    "04461f92-bc1b-4ff9-8792-d4b7f779a16b" : [
        ""
    ],
    "b2331cc9-d8d3-4336-ab4a-40822d922323" : [
        "崔晓东"
    ],
    "38e9d01d-9606-4480-91c1-88f02426c1c3" : [
        {
            "namePath" : [
                [
                    "非师范类"
                ]
            ],
            "idPath" : [
                [
                    "2523"
                ]
            ]
        }
    ],
    "e2e3ae4d-b918-40f4-8afb-2985f4d09da5" : [
        ""
    ],
    "29f3b35a-5f38-4409-a7c9-5237835996a6" : [
        {
            "namePath" : [
                [
                    "京版"
                ]
            ],
            "idPath" : [
                [
                    "2486"
                ]
            ]
        }
    ],
    "395fa07c-deb9-403d-b7a4-3d830a697395" : [
        [
            "否"
        ]
    ],
    "19a08f8b-4062-4186-adbc-bdd165b55f70" : [
        {
            "namePath" : [
                [
                    "否"
                ]
            ],
            "idPath" : [
                [
                    "2524"
                ]
            ]
        }
    ],
    "54cce162-130e-49ec-9a8d-bb694bd57df4" : [
        {
            "namePath" : [
                [
                    "非成人类"
                ]
            ],
            "idPath" : [
                [
                    "2520"
                ]
            ]
        }
    ],
    "76662052-8ebc-4029-bd1a-a4a63168a483" : [
        {
            "namePath" : [
                [
                    "三色"
                ]
            ],
            "idPath" : [
                [
                    "2483"
                ]
            ]
        }
    ],
    "96ed9834-3e33-4051-8ad4-42c337e258a5" : [
        null
    ],
    "6b8347af-ec70-4210-9fa7-6bc09f076210" : [
        {
            "namePath" : [
                []
            ],
            "idPath" : [
                []
            ]
        }
    ],
    "4334714e-274f-4232-bc6a-29791b5c1dab" : [
        {
            "namePath" : [
                [
                    "文科事业部艺术分社",
                    "高等教育文科出版事业部",
                    "高等教育出版社"
                ]
            ],
            "idPath" : [
                [
                    "5408",
                    "5372",
                    "5370"
                ]
            ]
        }
    ],
    "7530cb53-3303-4ef9-af86-b86fb94b234c" : [
        {
            "namePath" : [
                [
                    "教材"
                ]
            ],
            "idPath" : [
                [
                    "2500"
                ]
            ]
        }
    ]
}

and query like this

query

{
    "f18b456f-9879-403c-8d42-791dfc5b56b7" : {
          "$elemMatch" : {
            "namePath" : {
                "$elemMatch" : {
                    "$in" : ["文科事业部艺术分社"]
                }
            }
        }
    }
}

on 2.4.8 version look this document,at 2.6.5 find nothing.

particular reason why idPath and namePath are arrays of arrays, like save a book document ,the book can belongto some catalog,not belong to one category,and in form this input can repeat input.My project is diy form app,the user can drap html input、select、radio etc building a form,and any input、select and radio can put in a group,or repeat,or group repeat。so the page form contains many html input to input the book catalog,so i design the save schema like arrays of arrays。

I can't upload, send me instructions for a private upload,I and uplload my app preview

Comment by Ramon Fernandez Marina [ 27/Oct/14 ]

Hi rendong, we're still looking into this. In the meantime you may want to try a query like {"fieldsValue.namePath" : {$in : ["some word"]}} and see if that addresses your needs. Also, is there any particular reason why idPath and namePath are arrays of arrays?

It could be useful if you could send us a dataset and the detailed query you're using so we can investigate if there's an edge case here, specially on an schema containing arrays of arrays. Please let me know if you can share a sample dataset, and if you prefer not to upload it to the ticket I can send you instructions for a private upload.

Comment by rendong [ 25/Oct/14 ]

can you confirmed this bug?

Comment by rendong [ 22/Oct/14 ]

searchResult

{
 
    "1638f168-e3d8-4c0d-b7f4-e6f10ce47abc" : [ 
        {
            "namePath" : [ 
                [ 
                    "平装"
                ]
            ],
            "idPath" : [ 
                [ 
                    "2464"
                ]
            ]
        }
    ],
    "ef66e5bf-8a80-4b03-ae7c-7de19f576212" : [ 
        null
    ],
    "54eb75ac-85b6-4d43-aa9d-60246c60bd17" : [ 
        null
    ],
    "f18b456f-9879-403c-8d42-791dfc5b56b7" : [ 
        {
            "namePath" : [ 
                [ 
                    "绘画", 
                    "美术学", 
                    "艺术", 
                    "高等教育"
                ]
            ],
            "idPath" : [ 
                [ 
                    "861", 
                    "201", 
                    "41", 
                    "2547"
                ]
            ]
        }
    ],
    "7e8f3836-dea0-4a70-a1bd-b48b67d909ca" : [ 
        0
    ],
    "654c2783-b6f0-4629-80a8-ca8a365b0c08" : [ 
        "山水·花鸟临摹课教学(附辅学光盘)"
    ],
    "e2263056-7528-48d7-a9ce-ae3d02cec046" : [ 
        "21-10139-001"
    ],
    "019d4698-0709-4203-981d-216bfb5e0202" : [ 
        ""
    ],
    "e8ea9aee-1c15-4329-8415-ab17123cb64a" : [ 
        0
    ],
    "88207965-abde-46e6-8bf0-f2ec8b92b207" : [ 
        {
            "namePath" : [ 
                [ 
                    "16开"
                ]
            ],
            "idPath" : [ 
                [ 
                    "2466"
                ]
            ]
        }
    ],
    "04461f92-bc1b-4ff9-8792-d4b7f779a16b" : [ 
        ""
    ],
    "b2331cc9-d8d3-4336-ab4a-40822d922323" : [ 
        "崔晓东"
    ],
    "38e9d01d-9606-4480-91c1-88f02426c1c3" : [ 
        {
            "namePath" : [ 
                [ 
                    "非师范类"
                ]
            ],
            "idPath" : [ 
                [ 
                    "2523"
                ]
            ]
        }
    ],
    "e2e3ae4d-b918-40f4-8afb-2985f4d09da5" : [ 
        ""
    ],
    "29f3b35a-5f38-4409-a7c9-5237835996a6" : [ 
        {
            "namePath" : [ 
                [ 
                    "京版"
                ]
            ],
            "idPath" : [ 
                [ 
                    "2486"
                ]
            ]
        }
    ],
    "395fa07c-deb9-403d-b7a4-3d830a697395" : [ 
        [ 
            "否"
        ]
    ],
    "19a08f8b-4062-4186-adbc-bdd165b55f70" : [ 
        {
            "namePath" : [ 
                [ 
                    "否"
                ]
            ],
            "idPath" : [ 
                [ 
                    "2524"
                ]
            ]
        }
    ],
    "54cce162-130e-49ec-9a8d-bb694bd57df4" : [ 
        {
            "namePath" : [ 
                [ 
                    "非成人类"
                ]
            ],
            "idPath" : [ 
                [ 
                    "2520"
                ]
            ]
        }
    ],
    "76662052-8ebc-4029-bd1a-a4a63168a483" : [ 
        {
            "namePath" : [ 
                [ 
                    "三色"
                ]
            ],
            "idPath" : [ 
                [ 
                    "2483"
                ]
            ]
        }
    ],
    "96ed9834-3e33-4051-8ad4-42c337e258a5" : [ 
        null
    ],
    "6b8347af-ec70-4210-9fa7-6bc09f076210" : [ 
        {
            "namePath" : [ 
                []
            ],
            "idPath" : [ 
                []
            ]
        }
    ],
    "4334714e-274f-4232-bc6a-29791b5c1dab" : [ 
        {
            "namePath" : [ 
                [ 
                    "文科事业部艺术分社", 
                    "高等教育文科出版事业部", 
                    "高等教育出版社"
                ]
            ],
            "idPath" : [ 
                [ 
                    "5408", 
                    "5372", 
                    "5370"
                ]
            ]
        }
    ],
    "7530cb53-3303-4ef9-af86-b86fb94b234c" : [ 
        {
            "namePath" : [ 
                [ 
                    "教材"
                ]
            ],
            "idPath" : [ 
                [ 
                    "2500"
                ]
            ]
        }
    ]
}

Comment by J Rassi [ 20/Oct/14 ]

Could you please post the results of running this query on 2.4.8? I'd like to see what results you're expecting.

Comment by rendong [ 20/Oct/14 ]

why at 2.4.8 work ok,but at 2.6.5 not,if remove this feature in the future version,please tell me, I change my project ,thank you very much!

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