Awesome Martjin, let me know when you have it comitted and I'll check out the latest version. Again thanks!
On Sat, Jun 11, 2011 at 8:15 AM, Martijn v Groningen < martijn.is.h...@gmail.com> wrote: > Hi James, > > Good idea! I'll add a getAsFilterQuery method to the patch. > > Martijn > > On 6 June 2011 19:32, Jamie Johnson <jej2...@gmail.com> wrote: > > > Small error, shouldn't be using this.start but should instead be using > > Double.parseDouble(this.getValue()); > > and > > sdf.parse(count.getValue()); > > respectfully. > > > > On Mon, Jun 6, 2011 at 1:16 PM, Jamie Johnson <jej2...@gmail.com> wrote: > > > > > Thanks Martijn. I pulled your patch and it looks like what I was > looking > > > for. The original FacetField class has a getAsFilterQuery method which > > > returns the criteria to use as an fq parameter, I have logic which does > > this > > > in my class which works, any chance of getting something like this > added > > to > > > the patch as well? > > > > > > > > > public static class Numeric extends RangeFacet<Number, Number> { > > > > > > public Numeric(String name, Number start, Number end, Number gap) { > > > super(name, start, end, gap); > > > } > > > > > > public String getAsFilterQuery(){ > > > Double end = this.start.doubleValue() + > this.gap.doubleValue() > > - > > > 1; > > > return this.name + ":[" + this.start + " TO " + end + "]"); > > > } > > > > > > > > > } > > > > > > > > > and for dates (there's a parse exception below which I am not doing > > > anything with currently) > > > > > > public String getAsFilterQuery(){ > > > RangeFacet.Date dateCount = > > > (RangeFacet.Date)count.getRangeFacet(); > > > > > > DateMathParser parser = new > > DateMathParser(TimeZone.getDefault(), > > > Locale.getDefault()); > > > SimpleDateFormat sdf = new > > > SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); > > > > > > parser.setNow(dateCount.getStart()); > > > Date end = parser.parseMath(dateCount.getGap()); > > > String startStr = sdf.format(dateCount.getStart()) + "Z"; > > > String endStr = sdf.format(end) + "Z"; > > > String label = startStr + " TO " + endStr; > > > return facetField.getName() + ":[" + label + "]"); > > > > > > } > > > > > > > > > On Fri, Jun 3, 2011 at 7:05 AM, Martijn v Groningen < > > > martijn.is.h...@gmail.com> wrote: > > > > > >> Hi Jamie, > > >> > > >> I don't know why range facets didn't make it into SolrJ. But I've > > recently > > >> opened an issue for this: > > >> https://issues.apache.org/jira/browse/SOLR-2523 > > >> > > >> I hope this will be committed soon. Check the patch out and see if you > > >> like > > >> it. > > >> > > >> Martijn > > >> > > >> On 2 June 2011 18:22, Jamie Johnson <jej2...@gmail.com> wrote: > > >> > > >> > Currently the range and date faceting in SolrJ acts a bit > differently > > >> than > > >> > I > > >> > would expect. Specifically, range facets aren't parsed at all and > > date > > >> > facets end up generating filterQueries which don't have the range, > > just > > >> the > > >> > lower bound. Is there a reason why SolrJ doesn't support these? I > > have > > >> > written some things on my end to handle these and generate > > filterQueries > > >> > for > > >> > date ranges of the form dateTime:[start TO end] and I have a > function > > >> > (which > > >> > I copied from the date faceting) which parses the range facets, but > > >> would > > >> > prefer not to have to maintain these myself. Is there a plan to > > >> implement > > >> > these? Also is there a plan to update FacetField to not have end be > a > > >> > date, > > >> > perhaps making it a String like start so we can support date and > range > > >> > queries? > > >> > > > >> > > >> > > >> > > >> -- > > >> Met vriendelijke groet, > > >> > > >> Martijn van Groningen > > >> > > > > > > > > > > > > -- > Met vriendelijke groet, > > Martijn van Groningen >