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 roySolr <ro...@gmail.com> on 2011/06/16 15:20:00 UTC

Complex situation

Hello,

First i will try to explain the situation:

I have some companies with openinghours. Some companies has multiple seasons
with different openinghours. I wil show some example data :

Companyid          Startdate(d-m)  Enddate(d-m)     Openinghours_end
1                        01-01                01-04                 17:00
1                        01-04                01-08                 18:00
1                        01-08                31-12                 17:30

2                        01-01                31-12                 20:00

3                        01-01                01-06                 17:00
3                        01-06                31-12                 18:00

What i want is some facets on the left site of my page. They have to look
like this:

Closing today on:
17:00(23)
18:00(2)
20:00(1)

So i need to get the NOW to know which openinghours(seasons) i need in my
facet results. How should my index look like?
Can anybody helps me how i can save this data in the solr index?





--
View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3071936.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Complex situation

Posted by roySolr <ro...@gmail.com>.
Hello Lee,

I thought maybe this is a solution:

I can index every night the correct openinghours for next day. So
tonight(00:01) i can index the openinghours for 2011-24-06. My query in my
dih can looks like this:

select *																			from OPENINGHOURS o 
where o.startdate <= NOW() AND o.enddate >= NOW() 
AND o.companyid = '${OTHER_ENTITY.companyid}'

With this query i only save the openinghours for today. So i have only one
field(openinghours).

Openinghours
18:00

Then i can facets easilty on openinghours(facet.field=openinghours).

I don't know if i can update it every night without problems? I can use the
delte import?

--
View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3099468.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Complex situation

Posted by lee carroll <le...@googlemail.com>.
Hi Roy,

You have no relationship between time and date due to the
de-normalising of your data.

I don't have a good answer to this and I guess this is a "classic" question.

One approach is maybe to do the following:

make sure you have field collapsing available. trunk or a patch maybe

index not at the shop entity level but shop-opening level so your records are

shop fromDate     toDate        closingTime
1      12/12/2010  12/12/2011  18:00
1      12/12/2011  12/12/2012   20:00

Field collapse on shop id. Note this impacts on your number of records
and could be a lot of change for your app :-)

I'm also not sure if field collapsing will have the desired effect on
the facet counts and will behave as expected. Anyone with better
knowledge? is their a better way ?

Anyway, good luck with it Roy


On 23 June 2011 08:29, roySolr <ro...@gmail.com> wrote:
> Hello,
>
> I have change my db dates to the correct format like 2011-01-11T00:00:00Z.
>
> Now i have the following data:
>
>
> Manchester Store        2011-01-01T00:00:00Z
> 2011-31-03T00:00:00Z     18:00
> Manchester Store        2011-01-04T00:00:00Z
> 2011-31-12T00:00:00Z     20:00
>
> The "Manchester Store" has 2 seasons with different closing times(18:00 and
> 20:00). Now i have
> 4 fields in SOLR.
>
> Companyname             Manchester Store
> startdate(multiV)          2011-01-01T00:00:00Z, 2011-01-04T00:00:00Z
> enddate(multiV)           2011-31-03T00:00:00Z, 2011-31-12T00:00:00Z
> closingTime(multiV)      18:00, 20:00
>
> I want some facets like this:
>
> Open today(2011-23-06):
> 20:00(1)
>
> The facet query needs to look what's the current date and needs to use that
> closing time. My facet.query look like this:
>
> facet.query=startdate:[* TO NOW] AND enddate:[NOW TO *] AND
> closingTime:"18:00"
>
> This returns 1 count like this: 18:00(1)
>
> When i use this facet.query it returns also 1 result:
>
> facet.query=startdate:[* TO NOW] AND enddate:[NOW TO *] AND
> closingTime:"20:00"
>
> This result is not correct because NOW(2011-23-06) it's not open till 20:00.
> It looks like there is no link between the season and the closingTime. Can
> somebody helps me?? The fields in SOLR are not correct?
>
> Thanks Roy
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3098875.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Complex situation

Posted by roySolr <ro...@gmail.com>.
Hello,

I have change my db dates to the correct format like 2011-01-11T00:00:00Z.

Now i have the following data:


Manchester Store        2011-01-01T00:00:00Z               
2011-31-03T00:00:00Z     18:00
Manchester Store        2011-01-04T00:00:00Z               
2011-31-12T00:00:00Z     20:00

The "Manchester Store" has 2 seasons with different closing times(18:00 and
20:00). Now i have
4 fields in SOLR. 

Companyname             Manchester Store
startdate(multiV)          2011-01-01T00:00:00Z, 2011-01-04T00:00:00Z
enddate(multiV)           2011-31-03T00:00:00Z, 2011-31-12T00:00:00Z
closingTime(multiV)      18:00, 20:00

I want some facets like this:

Open today(2011-23-06):
20:00(1)

The facet query needs to look what's the current date and needs to use that
closing time. My facet.query look like this:

facet.query=startdate:[* TO NOW] AND enddate:[NOW TO *] AND
closingTime:"18:00"

This returns 1 count like this: 18:00(1)

When i use this facet.query it returns also 1 result:

facet.query=startdate:[* TO NOW] AND enddate:[NOW TO *] AND
closingTime:"20:00"

This result is not correct because NOW(2011-23-06) it's not open till 20:00.
It looks like there is no link between the season and the closingTime. Can
somebody helps me?? The fields in SOLR are not correct?

Thanks Roy

                        

--
View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3098875.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Complex situation

Posted by roySolr <ro...@gmail.com>.
Yes, current year. I understand that something like dd-mm-yy isn't possible.

I will fix this in my db,

Thanks for your help!

--
View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3090247.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Complex situation

Posted by Erick Erickson <er...@gmail.com>.
No, you can't as far as I know. The time format in Solr is fixed. Besides,
I don't know what NOW(dd-mm) would mean.... The day represented
by dd-mm in the current year?

You can probably make your db select emit the dates in the Solr format

Best
Erick

On Tue, Jun 21, 2011 at 3:37 AM, roySolr <ro...@gmail.com> wrote:
> Thanks it works!!
>
> I want to change the format of the NOW in SOLR. Is it possible? Now date
> format looks like this:
>
> yyyy-MM-dd T HH:mm:sss Z
>
> In my db the format is dd-MM. How can i fix the NOW so i can do something
> like * TO NOW(dd-mm)??
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3089632.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Complex situation

Posted by roySolr <ro...@gmail.com>.
Thanks it works!!

I want to change the format of the NOW in SOLR. Is it possible? Now date
format looks like this:

yyyy-MM-dd T HH:mm:sss Z

In my db the format is dd-MM. How can i fix the NOW so i can do something
like * TO NOW(dd-mm)??

--
View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3089632.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Complex situation

Posted by Erick Erickson <er...@gmail.com>.
It'll start to get ugly, but simply add clauses to your facet.query.
Note that you
can submit as many facet.query entries as you want. You can also configure
them as defaults in your request handler...

Something like
facet.query=startdate:[* TO NOW] AND enddate:[NOW TO *] AND openingHours:800

Note that I'd leave out the colon for simplicity, but that's up to you...
Best
Erick

On Mon, Jun 20, 2011 at 10:27 AM, roySolr <ro...@gmail.com> wrote:
> with this facet.query=startdate:[* TO NOW] AND enddate:[NOW TO *]  i will get
> all the results??
>
> Now i get the startdate and enddate from my db with the DIH.
>
> My schema.xml looks like this:
>
> <fieldType name="date" class="solr.TrieDateField" omitNorms="true"
> precisionStep="0" positionIncrementGap="0"/>
>
> <field name="startDate" type="date" indexed="true" stored="true"/>
> <field name="endDate" type="date" indexed="true" stored="true"/>
>
> When i use the facet.query i only get a count with companies. What i want is
> a count for openinghours.
> Maybe i forgot something?
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3086455.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Complex situation

Posted by roySolr <ro...@gmail.com>.
with this facet.query=startdate:[* TO NOW] AND enddate:[NOW TO *]  i will get
all the results??

Now i get the startdate and enddate from my db with the DIH.

My schema.xml looks like this:

<fieldType name="date" class="solr.TrieDateField" omitNorms="true"
precisionStep="0" positionIncrementGap="0"/>

<field name="startDate" type="date" indexed="true" stored="true"/>
<field name="endDate" type="date" indexed="true" stored="true"/>

When i use the facet.query i only get a count with companies. What i want is
a count for openinghours.
Maybe i forgot something?

--
View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3086455.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Complex situation

Posted by Erick Erickson <er...@gmail.com>.
DateMath (http://wiki.apache.org/solr/SolrQuerySyntax) contains the
keyword NOW,
and since you can form your facet queries as arbitrary Solr queries,
something like
facet.query=startdate:[* TO NOW] AND enddate:[NOW TO *] should work?

Best
Erick

On Mon, Jun 20, 2011 at 3:01 AM, roySolr <ro...@gmail.com> wrote:
> Hi,
>
> I want all the results, not only the results for current season.
> Let say i search for "supermarket", i get results 1, 2 and 3 in my
> response(previous post)
> Then i want on the left part some facets with openinghours. Let's say it is
> today 02/08/2011. Then my facets looks like this:
>
> 18:00(2)
> 20:00(1)
>
> Company 2 is open till 20:00. Company 1 and 3 are open till 18:00. So there
> are different openinghours dependent on season.
>
> I hope you understand with i mean.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3085129.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Complex situation

Posted by roySolr <ro...@gmail.com>.
Hi,

I want all the results, not only the results for current season.
Let say i search for "supermarket", i get results 1, 2 and 3 in my
response(previous post)
Then i want on the left part some facets with openinghours. Let's say it is
today 02/08/2011. Then my facets looks like this:

18:00(2)
20:00(1)

Company 2 is open till 20:00. Company 1 and 3 are open till 18:00. So there
are different openinghours dependent on season.

I hope you understand with i mean.



--
View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3085129.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Complex situation

Posted by Alexey Serba <as...@gmail.com>.
Am I right that you are only interested in results / facets for
current season? If it's so then you can index start/end dates as a
separate number fields and build your search filters like this
"fq=+start_date_month:[* TO 6] +start_date_day:[* TO 17]
+end_date_month:[* TO 6] +end_date_day:[16 TO *]" where 6/16 is
current month/day.

On Thu, Jun 16, 2011 at 5:20 PM, roySolr <ro...@gmail.com> wrote:
> Hello,
>
> First i will try to explain the situation:
>
> I have some companies with openinghours. Some companies has multiple seasons
> with different openinghours. I wil show some example data :
>
> Companyid          Startdate(d-m)  Enddate(d-m)     Openinghours_end
> 1                        01-01                01-04                 17:00
> 1                        01-04                01-08                 18:00
> 1                        01-08                31-12                 17:30
>
> 2                        01-01                31-12                 20:00
>
> 3                        01-01                01-06                 17:00
> 3                        01-06                31-12                 18:00
>
> What i want is some facets on the left site of my page. They have to look
> like this:
>
> Closing today on:
> 17:00(23)
> 18:00(2)
> 20:00(1)
>
> So i need to get the NOW to know which openinghours(seasons) i need in my
> facet results. How should my index look like?
> Can anybody helps me how i can save this data in the solr index?
>
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Complex-situation-tp3071936p3071936.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>