You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by alexw <aw...@crossview.com> on 2015/05/21 14:58:52 UTC

Price Range Faceting Based on Date Constraints

Hi,

I have an unique requirement to facet on product prices based on date
constraints, for which I have been thinking for a solution for a couple of
days now, but to no avail. The details are as follows:

1. Each product can have multiple prices, each price has a start-date and an
end-date.
2. At search time, we need to facet on price ranges ($0 - $5, $5-$20,
$20-$50...)
3. When faceting, a date is first determined. It can be either the current
system date or a future date (call it date X)
4. For each product, the price to be used for faceting has to meet the
following condition: start-date < date X, and date X < end-date, in other
words, date X has to fall within start-date and end-date.
5. My Solr version: 3.5

Hopefully I explained the requirement clearly. I have tried single price
field with multivalue and each price value has startdate and enddate
appended. I also tried one field per price with the field name containing
both startdate and enddate. Neither approach seems to work. Can someone
please shed some light as to how the index should be designed and what the
facet query should look like?

Thanks in advance for your help!



--
View this message in context: http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Price Range Faceting Based on Date Constraints

Posted by alexw <aw...@crossview.com>.
Hi Alex,

Thanks for the link to the presentation. I am going through the slides and
trying to figure out the time-sensitive search it talks about and how it
relates to the problem I am facing. It looks like it tries to solve the
problem of sku availability based on date, while in my case, all skus are
available, but the prices are time-sensitive, and faceting logic needs to
pick the right price for each sku when counting.



--
View this message in context: http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4206856.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Price Range Faceting Based on Date Constraints

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Did you look at Gilt's presentation from a while ago:
http://www.slideshare.net/trenaman/personalized-search-on-the-largest-flash-sale-site-in-america

Slides 33 on might be most relevant.

Regards,
   Alex.
----
Solr Analyzers, Tokenizers, Filters, URPs and even a newsletter:
http://www.solr-start.com/


On 21 May 2015 at 22:58, alexw <aw...@crossview.com> wrote:
> Hi,
>
> I have an unique requirement to facet on product prices based on date
> constraints, for which I have been thinking for a solution for a couple of
> days now, but to no avail. The details are as follows:
>
> 1. Each product can have multiple prices, each price has a start-date and an
> end-date.
> 2. At search time, we need to facet on price ranges ($0 - $5, $5-$20,
> $20-$50...)
> 3. When faceting, a date is first determined. It can be either the current
> system date or a future date (call it date X)
> 4. For each product, the price to be used for faceting has to meet the
> following condition: start-date < date X, and date X < end-date, in other
> words, date X has to fall within start-date and end-date.
> 5. My Solr version: 3.5
>
> Hopefully I explained the requirement clearly. I have tried single price
> field with multivalue and each price value has startdate and enddate
> appended. I also tried one field per price with the field name containing
> both startdate and enddate. Neither approach seems to work. Can someone
> please shed some light as to how the index should be designed and what the
> facet query should look like?
>
> Thanks in advance for your help!
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Price Range Faceting Based on Date Constraints

Posted by Alessandro Benedetti <be...@gmail.com>.
Just thinking a little bit on it, I should investigate more the .
SpatialRecursivePrefixTreeFieldType .

Each value of that field is it a Point ?
Actually each of our values must be  the rectangle.
Because the time frame and the price are a single value ( not only the
duration of the price 'end date - start date').
Could you give an example of the indexing as well ?

Cheers

2015-05-21 17:28 GMT+01:00 Alessandro Benedetti <be...@gmail.com>
:

> The geo-spatial idea is brilliant !
> Do you think translating the date into ms ?
> Alex, you should try that approach, it can work !
>
> Cheers
>
> 2015-05-21 16:49 GMT+01:00 Holger Rieß <Ho...@werkzeug-eylert.de>:
>
>> Give geospatial search a chance. Use the
>> 'SpatialRecursivePrefixTreeFieldType' field type, set 'geo' to false.
>> The date is located on the X-axis, prices on the Y axis.
>> For every price you get a horizontal line between start and end date.
>> Index a rectangle with height 0.001(< 1 cent) and width 'end date - start
>> date'.
>>
>> Find all prices that are valid on a given day or in a given date range
>> with the 'geofilt' function.
>>
>> The field type could look like (not tested):
>>
>> <fieldType name="price_date_range"
>> class="solr.SpatialRecursivePrefixTreeFieldType"
>>         geo="false" distErrPct="0.025" maxDistErr="0.000009"
>> units="degrees"
>>         worldBounds="1 0 366 100000000" />
>>
>> Faceting possibly can be done with a facet query for every of your price
>> ranges.
>> For example day 20, price range 0-5$, rectangle: <field name="pdr">20.0
>> 0.0 21.0 5.0</field>.
>>
>> Regards Holger
>>
>>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "Tyger, tyger burning bright
> In the forests of the night,
> What immortal hand or eye
> Could frame thy fearful symmetry?"
>
> William Blake - Songs of Experience -1794 England
>



-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Re: Price Range Faceting Based on Date Constraints

Posted by Alessandro Benedetti <be...@gmail.com>.
The geo-spatial idea is brilliant !
Do you think translating the date into ms ?
Alex, you should try that approach, it can work !

Cheers

2015-05-21 16:49 GMT+01:00 Holger Rieß <Ho...@werkzeug-eylert.de>:

> Give geospatial search a chance. Use the
> 'SpatialRecursivePrefixTreeFieldType' field type, set 'geo' to false.
> The date is located on the X-axis, prices on the Y axis.
> For every price you get a horizontal line between start and end date.
> Index a rectangle with height 0.001(< 1 cent) and width 'end date - start
> date'.
>
> Find all prices that are valid on a given day or in a given date range
> with the 'geofilt' function.
>
> The field type could look like (not tested):
>
> <fieldType name="price_date_range"
> class="solr.SpatialRecursivePrefixTreeFieldType"
>         geo="false" distErrPct="0.025" maxDistErr="0.000009"
> units="degrees"
>         worldBounds="1 0 366 100000000" />
>
> Faceting possibly can be done with a facet query for every of your price
> ranges.
> For example day 20, price range 0-5$, rectangle: <field name="pdr">20.0
> 0.0 21.0 5.0</field>.
>
> Regards Holger
>
>


-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Re: Price Range Faceting Based on Date Constraints

Posted by alexw <aw...@crossview.com>.
Thanks Holger and Alessandro, SpatialRecursivePrefixTreeFieldType  is a new
concept to me, and I need some time to dig into it and see how it can help
solve my problem.

Alex Wang
Technical Architect
Crossview, Inc.
C: (647) 409-3066
awang@crossview.com

On Thu, May 21, 2015 at 11:50 AM, Holger Rieß [via Lucene] <
ml-node+s472066n4206868h38@n3.nabble.com> wrote:

> Give geospatial search a chance. Use the
> 'SpatialRecursivePrefixTreeFieldType' field type, set 'geo' to false.
> The date is located on the X-axis, prices on the Y axis.
> For every price you get a horizontal line between start and end date.
> Index a rectangle with height 0.001(< 1 cent) and width 'end date - start
> date'.
>
> Find all prices that are valid on a given day or in a given date range
> with the 'geofilt' function.
>
> The field type could look like (not tested):
>
> <fieldType name="price_date_range"
> class="solr.SpatialRecursivePrefixTreeFieldType"
>         geo="false" distErrPct="0.025" maxDistErr="0.000009"
> units="degrees"
>         worldBounds="1 0 366 100000000" />
>
> Faceting possibly can be done with a facet query for every of your price
> ranges.
> For example day 20, price range 0-5$, rectangle: <field name="pdr">20.0
> 0.0 21.0 5.0</field>.
>
> Regards Holger
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4206868.html
>  To unsubscribe from Price Range Faceting Based on Date Constraints, click
> here
> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4206817&code=YXdhbmdAY3Jvc3N2aWV3LmNvbXw0MjA2ODE3fDE4OTQ1NzE1NTI=>
> .
> NAML
> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>

-- 
 <https://www.youtube.com/user/CrossViewInc1>
<http://www.crossview.com> <http://www.crossview.com>
<https://twitter.com/CrossView_Inc> 
<https://www.youtube.com/user/CrossViewInc1> 
<http://www.linkedin.com/company/crossview-inc./products> 
<https://plus.google.com/u/0/+Crossview/about> <http://blog.crossview.com>

This message may contain confidential and/or privileged information or information 
related to CrossView Intellectual Property. If you are not the addressee or 
authorized to receive this for the addressee, you must not use, copy, 
disclose, or take any action based on this message or any information 
herein. If you have received this message in error, please advise the 
sender immediately by reply e-mail and delete this message. Thank you for 
your cooperation.




--
View this message in context: http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4206951.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Price Range Faceting Based on Date Constraints

Posted by alexw <aw...@crossview.com>.
That's awesome! Thanks David. By the way, I own a copy of your terrific
book (Solr Enterprise Search Server) and am a big fan.

Alex Wang
Technical Architect
Crossview, Inc.
C: (647) 409-3066
awang@crossview.com

On Thu, May 21, 2015 at 11:40 PM, david.w.smiley@gmail.com [via Lucene] <
ml-node+s472066n4207029h29@n3.nabble.com> wrote:

> Indeed: https://github.com/dsmiley/SOLR-2155
>
> On Thu, May 21, 2015 at 8:59 PM alexw <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4207029&i=0>> wrote:
>
> > Thanks David. Unfortunately we are on Solr 3.5, so I am not sure whether
> > RPT
> > is available. If not, is there a way to patch 3.5 to make it work?
> >
> >
> >
> > --
> > View this message in context:
> >
> http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4207003.html
> > Sent from the Solr - User mailing list archive at Nabble.com.
> >
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4207029.html
>  To unsubscribe from Price Range Faceting Based on Date Constraints, click
> here
> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4206817&code=YXdhbmdAY3Jvc3N2aWV3LmNvbXw0MjA2ODE3fDE4OTQ1NzE1NTI=>
> .
> NAML
> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>

-- 
 <https://www.youtube.com/user/CrossViewInc1>
<http://www.crossview.com> <http://www.crossview.com>
<https://twitter.com/CrossView_Inc> 
<https://www.youtube.com/user/CrossViewInc1> 
<http://www.linkedin.com/company/crossview-inc./products> 
<https://plus.google.com/u/0/+Crossview/about> <http://blog.crossview.com>

This message may contain confidential and/or privileged information or information 
related to CrossView Intellectual Property. If you are not the addressee or 
authorized to receive this for the addressee, you must not use, copy, 
disclose, or take any action based on this message or any information 
herein. If you have received this message in error, please advise the 
sender immediately by reply e-mail and delete this message. Thank you for 
your cooperation.




--
View this message in context: http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4207084.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Price Range Faceting Based on Date Constraints

Posted by "david.w.smiley@gmail.com" <da...@gmail.com>.
Indeed: https://github.com/dsmiley/SOLR-2155

On Thu, May 21, 2015 at 8:59 PM alexw <aw...@crossview.com> wrote:

> Thanks David. Unfortunately we are on Solr 3.5, so I am not sure whether
> RPT
> is available. If not, is there a way to patch 3.5 to make it work?
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4207003.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Price Range Faceting Based on Date Constraints

Posted by alexw <aw...@crossview.com>.
Thanks David. Unfortunately we are on Solr 3.5, so I am not sure whether RPT
is available. If not, is there a way to patch 3.5 to make it work?



--
View this message in context: http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4207003.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Price Range Faceting Based on Date Constraints

Posted by David Smiley <da...@gmail.com>.
Another more modern option, very related to this, is to use DateRangeField in 5.0.  You have full 64 bit precision.  More info is in the Solr Ref Guide.

If Alessandro sticks with RPT, then the best reference to give is this:
http://wiki.apache.org/solr/SpatialForTimeDurations

~ David
https://www.linkedin.com/in/davidwsmiley

> On May 21, 2015, at 11:49 AM, Holger Rieß <Ho...@werkzeug-eylert.de> wrote:
> 
> Give geospatial search a chance. Use the 'SpatialRecursivePrefixTreeFieldType' field type, set 'geo' to false.
> The date is located on the X-axis, prices on the Y axis.
> For every price you get a horizontal line between start and end date. Index a rectangle with height 0.001(< 1 cent) and width 'end date - start date'.
> 
> Find all prices that are valid on a given day or in a given date range with the 'geofilt' function.
> 
> The field type could look like (not tested):
> 
> <fieldType name="price_date_range" class="solr.SpatialRecursivePrefixTreeFieldType"
> 	geo="false" distErrPct="0.025" maxDistErr="0.000009" units="degrees"
> 	worldBounds="1 0 366 100000000" />
> 
> Faceting possibly can be done with a facet query for every of your price ranges.
> For example day 20, price range 0-5$, rectangle: <field name="pdr">20.0 0.0 21.0 5.0</field>.
> 
> Regards Holger
> 


AW: Price Range Faceting Based on Date Constraints

Posted by Holger Rieß <Ho...@werkzeug-eylert.de>.
Give geospatial search a chance. Use the 'SpatialRecursivePrefixTreeFieldType' field type, set 'geo' to false.
The date is located on the X-axis, prices on the Y axis.
For every price you get a horizontal line between start and end date. Index a rectangle with height 0.001(< 1 cent) and width 'end date - start date'.

Find all prices that are valid on a given day or in a given date range with the 'geofilt' function.

The field type could look like (not tested):

<fieldType name="price_date_range" class="solr.SpatialRecursivePrefixTreeFieldType"
	geo="false" distErrPct="0.025" maxDistErr="0.000009" units="degrees"
	worldBounds="1 0 366 100000000" />

Faceting possibly can be done with a facet query for every of your price ranges.
For example day 20, price range 0-5$, rectangle: <field name="pdr">20.0 0.0 21.0 5.0</field>.

Regards Holger


Re: Price Range Faceting Based on Date Constraints

Posted by alexw <aw...@crossview.com>.
Thanks Alessandro. I am implementing this in the Hybris framework. It is not
easy to create nested documents during indexing using the Hybris Solr
indexer. So I am trying to avoid additional documents and cores if at all
possible.



--
View this message in context: http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817p4206854.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Price Range Faceting Based on Date Constraints

Posted by Alessandro Benedetti <be...@gmail.com>.
Hi Alex,
this is not a simple problem.
In your domain we can consider a Product as a document and the list of
<Price> nested Documents.
Ideally we would model the Product as the father and the prices as children.
Each <Price> will be defined by :


   -
*start_date *
   -
*end_date *
   -
*price *
   - *productId*

We can define 2 collections this way and play with Joins and faceting.
Take a look here :

http://lucene.472066.n3.nabble.com/How-do-I-get-faceting-to-work-with-Solr-JOINs-td4147785.html#a4148838

If redundancy of data is not a problem for you, you can proceed with a
simple approach where you add redundant documents.
Each document will have the start_date,end_date and price as single value
fields.
In the redundant scenario, the approach to follow is quite easy :
- always filtering by date the docs and then proceed faceting .

Cheers

2015-05-21 13:58 GMT+01:00 alexw <aw...@crossview.com>:

> Hi,
>
> I have an unique requirement to facet on product prices based on date
> constraints, for which I have been thinking for a solution for a couple of
> days now, but to no avail. The details are as follows:
>
> 1. Each product can have multiple prices, each price has a start-date and
> an
> end-date.
> 2. At search time, we need to facet on price ranges ($0 - $5, $5-$20,
> $20-$50...)
> 3. When faceting, a date is first determined. It can be either the current
> system date or a future date (call it date X)
> 4. For each product, the price to be used for faceting has to meet the
> following condition: start-date < date X, and date X < end-date, in other
> words, date X has to fall within start-date and end-date.
> 5. My Solr version: 3.5
>
> Hopefully I explained the requirement clearly. I have tried single price
> field with multivalue and each price value has startdate and enddate
> appended. I also tried one field per price with the field name containing
> both startdate and enddate. Neither approach seems to work. Can someone
> please shed some light as to how the index should be designed and what the
> facet query should look like?
>
> Thanks in advance for your help!
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Price-Range-Faceting-Based-on-Date-Constraints-tp4206817.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England