0

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

4

2 回答 2

0

据我了解,您有一个产品(例如 ABC)。价格和尺寸之间的关系就像

10 > 尺寸A

15 > 尺寸B

30 > 尺寸A

您为什么不保存多个 Solr 文档,而不是为一个产品保留每个文档?让我们有一个产品ID或其他东西。Solr 中没有一个文档,而是有 3 个文档。

productid:1 产品名称:ABC 尺寸:SizeA 价格:10

productid:2 产品名称:ABC 尺寸:Sizeb 价格:15

productid:3 产品名称:ABC 尺寸:SizeA 价格:30

现在您的查询“ price >=15 AND a Size = sizeA ”将返回匹配的文档。

于 2014-01-16T06:28:21.063 回答
0

你可以有一个动态字段

<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>
于 2015-01-09T12:02:20.117 回答