I have a collection of categories as below.
{
"_id": ObjectId("5353a17dfcda358c1050d1ed"),
"name": "Motorcyles",
"tags": {"Vehicle","two wheeler","Bikes"}
},
{
"_id": ObjectId("5353a17dfcda358c105bde4c"),
"name": "Automobiles",
"tags": {"Vehicle","Cars","Bikes", "two wheeler", "four wheeler"}
},
{
"_id": ObjectId("5353a17dfcda358c105fd5e701),
"name": "Cars",
"tags": {"Vehicle","Cars","four wheeler"}
}
Now I want to list the categories using doctrine ODM query builder and filter categories matching name or values stored in tags. (i.e when search text is car then the result should be two categories - Automobiles and Cars as Automobiles has cars in tag and there is a category with name Cars).
I hope you understood the situation.
I am using Symfony2 and doctrine-odm. I have tried using elemMatch() but I could not find the solution. I got the solutions for only the indexed array with key and value. But In my case, tags contains the array with out keys.
Could anyone please help.