title: Indexing related information in Apache Solr
body: <p>Just wanted to some advice about how to index information (two fields) that are related into SOLR.</p>
  <p>Let's say I have two fields like this:</p>
  <pre><code>&quot;name&quot;: [&quot;XF300A01&quot;,
             &quot;XF300A23&quot;,
             &quot;XF300A22&quot;,
             &quot;XF300A03&quot;,
             ],
  &quot;value&quot;: [&quot;0&quot;,
             &quot;1&quot;,
             &quot;100&quot;,
             &quot;3&quot;,
             &quot;4&quot;,
             &quot;30&quot;,
             &quot;163&quot;,
             &quot;10&quot;],
  </code></pre>
  <p>In this example, we might search for say: <code>name: XF300A01 and value: 3</code></p>
  <p>Here we are looking for any documents that have name XF300A01 and also any documents that have value 3. But what we actually want to look for is the name that has a given value. For example, we would want to say search where we have XF300A01 = 3.</p>
  <p>At the moment, the data is not stored in this way. I was wondering what the best way to index the information is so it is related. I've read it could be as simple as concating say the name and value like XF300A01_3</p>
  <p>I saw this link: <a href="https://bryanbende.com/development/2015/01/31/concatenating-fields-with-apache-solr" rel="nofollow noreferrer">https://bryanbende.com/development/2015/01/31/concatenating-fields-with-apache-solr</a></p>
  <p>But I'm storing this information programmatically via Java so I can create any structure or values that need to be stored easily.</p>
  <p>I thought something like this could be the way:</p>
  <pre><code>&quot;name&quot;: [&quot;XF300A01&quot;,
             &quot;XF300A23&quot;,
             &quot;XF300A22&quot;,
             &quot;XF300A03&quot;,
             ],
  &quot;value&quot;: [&quot;0&quot;,
             &quot;1&quot;,
             &quot;100&quot;,
             &quot;3&quot;,
             &quot;4&quot;,
             &quot;30&quot;,
             &quot;163&quot;,
             &quot;10&quot;],
  &quot;name_value&quot;: [
             &quot;XF300A01_100&quot;,
             &quot;XF300A03_3&quot;],
  </code></pre>
  <p>Any suggestions appreciated.</p>
  <p>Thanks</p>