title: Mongodb Index Suggestions
body: <p>First time I am using mongodb, I need help with index suggestions. In my mongo database I have collection with nearly 15 million documents.Attached is json document.  The "playfields" is array of embedded documents . I frequently run following queries. The data  in value field is stored in different datatypes (string, int). My question is what is best index to add on this documents to cover below queries:</p>
  
  <pre><code>db.playfieldvalues.find({"playfields":{$elemMatch:{ID:"Play.NHL.NHLEventX", value: -47}}})
  </code></pre>
  
  <p><strong>Sample JSON Doc:</strong></p>
  
  <pre><code>{
    "Playid": "9dbc7763-7d47-44e9-8b11-e1ec864407bb",
    "Playfields": [
      {
        "ID": "XInfo_OffTeam",
        "Value": "Dallas",
        "TS": "201709291148408452"
      },
      {
        "ID": "XInfo_DefTeam",
        "Value": "Kansas",
        "TS": "201709291148456267"
      },
      {
        "ID": "XInfo_Period",
        "Value": 1,
        "TS": "201709291148456267"
      },
      {
        "ID": "XInfo_OffScore",
        "Value": 38,
        "TS": "201709291148456267"
      },
      {
        "ID": "XInfo_DefScore",
        "Value": 21,
        "TS": "201709291148456267"
      },
      {
        "ID": "XInfo_PlayAction",
        "Value": "Y",
        "TS": "201709291148456267"
      }
    ]
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mw8EI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mw8EI.jpg" alt="enter image description here"></a></p>