Yes sure, this is an example of one of my document :
_id: 1,
...
attributes: [
{ key: 'totalPrice', value: 40600 },
{ key: 'mileage', value: 67953 },
{ key: 'firstRegistrationDate', value: 2019 },
{ key: 'make', value: 9 },
{ key: 'model', value: 19155 },
{ key: 'hp', value: 190 },
{ key: 'numberOfSeats', value: 5 },
{
key: 'modelVersionInput',
value: '40 TDI Q SPORT LM20 eSITZE KAMERA AHK ACC '
},
{ key: 'fuelCategory', value: 1 },
{ key: 'transmissionType', value: 1 },
{ key: 'numberOfDoors', value: 5 },
{ key: 'bodyType', value: 3 },
{ key: 'bodyColor', value: 10 },
{
key: 'equipments',
value: [4, 50, 20, 130, 187, 140, 239, 38, 133, 158, 139, 6, 34, 221, 23, 124, 224, 157, 153, 11],
}
],
Make, model, fuelCategory, transmissionType, bodyType, bodyColor, equipments values are ids FYI.
The customer has to be able to query vehicles with as much criteria he wants. For example, something like this :
{
$and: [
{ "attributes.key": "make", "attributes.value": 9 },
{
$or: [
{ "attributes.key": "model", "attributes.value": 19155 },
{ "attributes.key": "model", "attributes.value": 19156 },
{ "attributes.key": "model", "attributes.value": 19157 },
]
},
{ attributes: { key: "totalPrice", value: { $lte: 50000 } } },
{
$or: [
{ "attributes.key": "bodyColor", "attributes.value": 1 },
{ "attributes.key": "bodyColor", "attributes.value": 2 },
{ "attributes.key": "bodyColor", "attributes.value": 10 },
]
},
{ "attributes.key": "equipments", "attributes.value": 4 },
{ "attributes.key": "equipments", "attributes.value": 50 },
{ "attributes.key": "equipments", "attributes.value": 20 },
{ "attributes.key": "equipments", "attributes.value": 130 },
]
}
Moreover, if possible I would like to sort these results, by totalPrice asc and desc, mileage, firstRegistrationDate…
Regards,