title: unspecified index when searching data with firebase cloud function on nested object running nested Query
body: <p>I'm using fire-base to retrieve nested data of users node, and while running query I'm facing this issue fetching data from fire-base database.</p>
  
  <blockquote>
    <p>Consider adding ".indexOn": "userId" at
    /users/YJdwgRO08nOmC5HdEokr1NqcATx1/following/users to your security
    rules for better performance.</p>
  </blockquote>
  
  <p><strong>Database Structure:</strong></p>
  
  <pre><code> "users" : {
      "1vWvSXDQITMmKdUIY7SYoLA1MgU2" : {
        "userEmail" : "test2kawee@gmail.com",
        "userId" : "1vWvSXDQITMmKdUIY7SYoLA1MgU2",
        "userName" : "Malik Abdul Kawee",
        "userPhoneNumber" : "",
        "userProfileImage" : "https://pbs.twimg.com/profile_images/1018741325875867648/ZnKeUiOJ_400x400.jpg"
      },
      "YJdwgRO08nOmC5HdEokr1NqcATx1" : {
        "following" : {
          "1vWvSXDQITMmKdUIY7SYoLA1MgU2" : {
            "currentFollowingUserId" : "YJdwgRO08nOmC5HdEokr1NqcATx1",
            "userEmail" : "test2kawee@gmail.com",
            "userId" : "1vWvSXDQITMmKdUIY7SYoLA1MgU2",
            "userName" : "Malik Abdul Kawee",
            "userPhoneNumber" : "",
            "userProfileImage" : "https://pbs.twimg.com/profile_images/1018741325875867648/ZnKeUiOJ_400x400.jpg"
          }
        },
        "userEmail" : "test2atif@gmail.com",
        "userId" : "YJdwgRO08nOmC5HdEokr1NqcATx1",
        "userName" : "Atif AbbAsi",
        "userPassword" : "test123",
        "userPhoneNumber" : "",
        "userProfileImage" : "http://paperlief.com/images/enrique-iglesias-body-workout-wallpaper-4.jpg"
      }
    }
  </code></pre>
  
  <p><strong>Database Rules:</strong></p>
  
  <pre><code>    "users": {
       ".indexOn":  ["userId","currentFollowingUserId",".value"],
         "$userId": {
           "following": {
          //"$userId": {
               ".indexOn":  ["userId","currentFollowingUserId",".value"]
          }
      //}
         } 
  }
  </code></pre>
  
  <p><strong>Function Query:</strong></p>
  
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp(functions.config().firebase);
  
  
  exports.sendFollowingNotifications = functions.database.ref('/users/{userId}/following/{followingId}')
         //.onWrite(event =&gt; {
           .onCreate((snap,context) =&gt; {  
  
  
          console.info("Child value is val() " ,snap);
  
  
          var childNodeValue=snap.val();
  
          var topic=childNodeValue.userId;
  
          //var ref = firebase.database().ref.child('users');
  
          //console.log("testing ref pathName : " ,snap.ref.parent.parent.parent.pathname);
      //  console.log("testing ref : " ,snap.ref.parent.parent.parent.path);
  
          //var ref = admin.database().ref("users");
  
          //.child('users')
  
          return snap.ref.parent.parent.parent.orderByChild("userId").equalTo(childNodeValue.currentFollowingUserId)
  
       // .on('child_changed').then(snapshot =&gt; { once('value')
           .once('value', function(snapshot){ 
          var parentNodeValue=snapshot.val();
  
          console.info("Topic ID " ,topic);
  
          console.info("Parent value is val() " ,snapshot.val());
  
                var payload = {
              data: {
                  username: parentNodeValue.userName,
                  imageurl:parentNodeValue.userProfileImage,
                  description:"Started Following You"
              }
          };
  
  
  
             // Send a message to devices subscribed to the provided topic.
          return admin.messaging().sendToTopic(topic, payload)
              .then(function (response) {
                  // See the MessagingTopicResponse reference documentation for the
                  // contents of response.
                  console.log("Successfully sent message:", response);
                  return response;
              })
              .catch(function (error) {
                  console.log("Error sending message:", error);
                  return error;
              });
  
        });
  
  
  
  
  
  
  
  
        });
  </code></pre>
  
  <blockquote>
    <p>return
    snap.ref.parent.child('users').orderByChild("userId").equalTo(childNodeValue.currentFollowingUserId)</p>
  </blockquote>
  
  <p>I think the problem is with this query , My first query on following node is returning me data but when I'm retrieving data of its parent node user, I'm getting warning.</p>
  
  <p>I tried to use <code>functions.database.ref</code> but it gave me below exception.</p>
  
  <pre><code>so I tried using this `snap.ref.parent.`to get reference of parent node.
  </code></pre>
  
  <blockquote>
    <p>Firebase Functions, admin.database().ref(…) is not a function</p>
    
    <p>Firebase Functions, functions.database().ref(…) is not a function</p>
  </blockquote>