Question

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

Was it helpful?

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>

OTHER TIPS

As per my understanding, you have a product (say, ABC). The relation between the price and size are like

10 > SizeA

15 > SizeB

30 > SizeA

Instead of keeping each document for a product, why don't you save multiple Solr doc? Let's have a product id or something. Instead of having one document in Solr, have 3 document.

productid:1 productname:ABC size:SizeA price:10

productid:2 productname:ABC size:Sizeb price:15

productid:3 productname:ABC size:SizeA price:30

Now your query "price >=15 AND a Size = sizeA" will return the matched document.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top