solrwcs

SolR query with combinaison / Fields relations


I'm using SolR 3.5.

My datas are like this:

<doc>
  <arr name="myField">
    <str>10_SizeA</str>
    <str>15_SizeB</str>
    <str>30_SizeA</str>
  </arr>
</doc>

(data's structure can be modified if necessary, but need to stay grouped in 1 document node).

It means that I have 1 product with price = 10 and Size = sizeA, an other with price = 15, ...

I want to be able to return my document if I query for a price >=15 AND a Size = sizeA. But if a look for a Price >= 30 AND a Size = sizeB, I dont want to find it.

Is there any way to do that?

EDIT : For a better understanding, let me explain the relation between all theses values. The is my product. Each in the multivalue field "myField" are the informations about an Item. Price_Size So each lines are "linked" and must stay related.

But if there is a way to keep that relation with an other structure, please go ahead and propose.

Thanks Reading, Dekx


Solution

  • You could have a dynamic field with

    <field name="prices" type="float" indexed="true" stored="true" multiValued="false"/> 
    <dynamicField name="price_*" type="float" indexed="true" stored="true" multiValued="true"/>
    <copyField source="price_*" dest="prices"/>
    
    <doc>
       <str name="price_A">10</str>
       <str name="price_B">15</str>
       <str name="price_C">30</str>
       <arr name="prices">
          <str>10</str>
          <str>15</str>
          <str>30</str>
       </arr>
    </doc>