У меня проблемы с моим MongoRegex, запрос ниже:
db.part_instances.find({
'Part.name' : /Bauteilname/i,
'Part.version' : /1/i,
'LocationInstanceLinks' : {'$in' : [1001]},
'Part.Manufacturer.name':/Hersteller/i
});
Возвращаемые данные следующие:
Как вы заметите, должен совпадать только один из 4 результатов или я что-то не так делаю?
[
{
"_id": 1211,
"Category": {
"name": "",
"id": "",
"building_id": 1001
},
"Craft": {
"name": "",
"id": "",
"building_id": 1001
},
"LocationInstanceLinks": [
1001
],
"MaintenanceTypeLinks": [],
"Part": {
"name": "Bauteilname1",
"id": 1203,
"sort_name": "bauteilname1",
"sort_manufacturer": "hersteller2",
"version": "1",
"buildyear": "",
"status": "local_object",
"Manufacturer": {
"name": "Hersteller2",
"id": "1202"
},
"Building": {
"id": 1001,
"name": "Gebäude_dl1.admin",
"location_instance_id": 1001
}
},
"article_number": "",
"comments": "",
"deleted": 1,
"deleted_date": "Thu, 08 Sep 2011 09:57:22 +0200",
"ean_number": "",
"following_product": "",
"implementation_date": "08.09.2011",
"in_room_position": "",
"manufacturer_number": ""
},
{
"_id": 1212,
"Category": {
"name": "",
"id": "",
"building_id": 1001
},
"Craft": {
"name": "",
"id": "",
"building_id": 1001
},
"LocationInstanceLinks": [
1001
],
"MaintenanceTypeLinks": [],
"Part": {
"name": "Bauteilname",
"id": 1201,
"sort_name": "bauteilname",
"sort_manufacturer": "hersteller",
"version": "1",
"buildyear": "",
"status": "local_object",
"Manufacturer": {
"name": "Hersteller",
"id": "1201"
},
"Building": {
"id": 1001,
"name": "Gebäude_dl1.admin",
"location_instance_id": 1001
}
},
"article_number": "",
"comments": "",
"deleted": 0,
"deleted_date": "Thu, 08 Sep 2011 10:07:36 +0200",
"ean_number": "",
"following_product": "",
"implementation_date": "",
"in_room_position": "",
"manufacturer_number": ""
},
{
"_id": 1214,
"Category": {
"name": "",
"id": "",
"building_id": 1001
},
"Craft": {
"name": "",
"id": "",
"building_id": 1001
},
"LocationInstanceLinks": [
1001
],
"MaintenanceTypeLinks": [],
"Part": {
"name": "Bauteilname_Fenster",
"version": "1",
"buildyear": "",
"status": "local_object",
"sort_name": "bauteilname_fenster",
"sort_manufacturer": "hersteller_fenster",
"Manufacturer": {
"name": "Hersteller_Fenster",
"id": 1204
},
"Building": {
"location_instance_id": 1001,
"name": "Gebäude_dl1.admin",
"id": 1001
},
"id": 1206
},
"ServicecartLinks": [],
"article_number": "",
"comments": "",
"deleted": 1,
"deleted_date": "Thu, 08 Sep 2011 10:07:36 +0200",
"ean_number": "",
"following_product": "",
"implementation_date": "08.09.2011",
"in_room_position": "",
"manufacturer_number": "",
"parents": []
},
{
"_id": 1213,
"Category": {
"name": "",
"id": "",
"building_id": 1001
},
"Craft": {
"name": "",
"id": "",
"building_id": 1001
},
"LocationInstanceLinks": [
1001
],
"MaintenanceTypeLinks": [],
"Part": {
"Building": {
"location_instance_id": 1001,
"name": "Gebäude_dl1.admin",
"id": 1001
},
"Manufacturer": {
"name": "Hersteller_Glas",
"id": "1203"
},
"buildyear": "",
"name": "Bauteilname_Glas",
"sort_manufacturer": "hersteller_glas",
"sort_name": "bauteilname_glas",
"status": "local_object",
"version": "1",
"id": 1205
},
"ServicecartLinks": [],
"article_number": "",
"comments": "",
"deleted": 1,
"deleted_date": "Thu, 08 Sep 2011 10:07:36 +0200",
"ean_number": "",
"following_product": "",
"implementation_date": "08.09.2011",
"in_room_position": "",
"manufacturer_number": ""
},
{
"_id": 1215,
"Category": {
"name": "",
"id": "",
"building_id": 1001
},
"Craft": {
"name": "",
"id": "",
"building_id": 1001
},
"LocationInstanceLinks": [
1001
],
"MaintenanceTypeLinks": [],
"Part": {
"name": "Bauteilname2",
"id": 1207,
"sort_name": "bauteilname2",
"sort_manufacturer": "hersteller2",
"version": "1",
"buildyear": "",
"status": "local_object",
"Manufacturer": {
"name": "Hersteller2",
"id": 1202
},
"Building": {
"id": 1001,
"name": "Gebäude_dl1.admin",
"location_instance_id": 1001
}
},
"article_number": "",
"comments": "",
"deleted": 1,
"deleted_date": "Thu, 08 Sep 2011 10:07:36 +0200",
"ean_number": "",
"following_product": "",
"implementation_date": "08.09.2011",
"in_room_position": "",
"manufacturer_number": ""
},
{
"_id": 1216,
"Category": {
"name": "",
"id": "",
"building_id": 1001
},
"Craft": {
"name": "",
"id": "",
"building_id": 1001
},
"LocationInstanceLinks": [
1001
],
"MaintenanceTypeLinks": [],
"Part": {
"name": "Bauteilname_Fenster",
"id": 1206,
"sort_name": "bauteilname_fenster",
"sort_manufacturer": "hersteller_fenster",
"version": "1",
"buildyear": "",
"status": "local_object",
"Manufacturer": {
"name": "Hersteller_Fenster",
"id": 1204
},
"Building": {
"id": 1001,
"name": "Gebäude_dl1.admin",
"location_instance_id": 1001
}
},
"PartInstanceLinks": [],
"article_number": "",
"comments": "",
"ean_number": "",
"following_product": "",
"implementation_date": "08.09.2011",
"in_room_position": "",
"manufacturer_number": ""
},
{
"_id": 1217,
"Category": {
"name": "",
"id": "",
"building_id": 1001
},
"Craft": {
"name": "",
"id": "",
"building_id": 1001
},
"LocationInstanceLinks": [
1001
],
"MaintenanceTypeLinks": [],
"Part": {
"name": "Bauteilname_Glas",
"id": 1205,
"sort_name": "bauteilname_glas",
"sort_manufacturer": "hersteller_glas",
"version": "1",
"buildyear": "",
"status": "local_object",
"Manufacturer": {
"name": "Hersteller_Glas",
"id": "1203"
},
"Building": {
"id": 1001,
"name": "Gebäude_dl1.admin",
"location_instance_id": 1001
}
},
"PartInstanceLinks": [],
"article_number": "",
"comments": "",
"ean_number": "",
"following_product": "",
"implementation_date": "08.09.2011",
"in_room_position": "",
"manufacturer_number": ""
}
]