So, you have a user-visible field that is in 'seconds since epoch'. You would like to index this, and the Solr date features are handy. And, you do not have an application prepping the data to index, nor do you have a UI that can receive Solr dates and turn them back into 'seconds since epoch'.
During indexing: the basic Solr XmlUpdateHandler does not have a facility for this. In the DataImportHandler you can add Javascript that takes your 'seconds since epoch', adds the delta between your epoch and 1/1/1970, and multiplies by 1000. During query: there are several programmable output writers, including velocity, ruby, and xslt (in decreasing order of useability), and you can preprocess the output with one of these. You can even create completely different formats for the output. On Mon, Apr 12, 2010 at 10:55 AM, Shawn Heisey <s...@elyograg.org> wrote: > I am trying to boost relevancy based on a date field with dismax, and I've > included the requestHandler config below. The post_date field in my > database is simple UNIX time, seconds since epoch. It's in a MySQL bigint > field, so I've stored it as a tlong in Solr. This filed is required by our > application in integer format. > > You can see a boost function commented out below that I tried to use, which > should multiply the post_date by 1000 to match the Solr way of milliseconds > since epoch, then use a reciprocal example similar to one I found on the > Solr Wiki. When I uncomment it, I get an error message: > > Problem accessing /solr/ncmain/select. Reason: > undefined field product(post_date > > Lance Norskog mentioned that boost functions are slow, and suggested that I > use something like the following query, which I am willing to try, but I > first have to get my "seconds since epoch" into a format that Solr can use. > So, I need two things that I cannot figure out how to do. One is > schema.xml (or DIH, maybe?) config to convert the date format into an > additional field, the other is exactly what to put in the dismax > requestHandler to automatically include the boost. > > [NOW-6MONTHS TO NOW]^5.0 , > [NOW-1YEARS TO NOW-6MONTHS]^3.0 > [NOW-2YEARS TO NOW-1YEARS]^2.0 > [* TO NOW-2YEARS]^1.0 > > My current dismax requestHandler, some of which is still a work in progress: > > <requestHandler name="dismax" class="solr.SearchHandler"> > <lst name="defaults"> > <str name="defType">dismax</str> > <bool name="partialResults">true</bool> > <int name="timeAllowed">6000</int> > <str name="echoParams">explicit</str> > <int name="rows">50</int> > <str > name="shards">idxinc:8983/solr/live,idxst0-b:8983/solr/live,idxst1-b:8983/solr/live,idxst2-b:8983/solr/live,idxst3-b:8983/solr/live,idxst4-b:8983/solr/live,idxst5-b:8983/solr/live</str> > <float name="tie">0.1</float> > <str name="qf">doc_id^5 text_preview^1.25 ft_text keywords^0.75 > ft_dname^1.25</str> > <str name="pf">doc_id^5 text_preview^1.25 ft_text keywords^0.75 > ft_dname^1.25</str> > <!-- > <str name="bf">recip(ms(NOW,product(post_date,1000)),3.17e-11,1,1)</str> > --> > <str name="fl">score,*</str> > <str name="mm">0<-1 4<-50%</str> > <str name="q.alt">*:*</str> > </lst> > </requestHandler> > > -- Lance Norskog goks...@gmail.com