Mongodb search key /attrinute having space
<p>I have thousands of items in my gameItem collection with the following as example.</p>

<pre><code>{
    "weapon name 1":{price:01},
    "weapon name 2":{price:100}
}
</code></pre>

<p>and I run a query like so in shell</p>

<pre><code>db.gameItems.find({"weapon name 1":{$exists:1}})
</code></pre>

<p>nothing returns but it works when my keys don't have spaces...</p>

<p>First questions: Is there a way to search key values with spaces?
Second question: Should I change my data model to be like so?:</p>

<pre><code>   {
      weapon:{name: "weapon name 1", price:01}
      weapon:{name: "weapon name 2", price:100}
   }
</code></pre>

<p>And then add an index to the weapon name field? Does this increase search performance with only 2 fields in each weapon document?</p>

<p>Thanks</p>

<p>Edit: </p>

<p>Apologies, it appears the db collection gameItems actually looks like this...</p>

<pre><code>{
   last_updated:"2016-04-01",
   items:{
          "weapon name 1":{price:01},
          "weapon name 2":{price:100}
   }
}
</code></pre>

<p>so how would I search for them inside the item document?</p>