Hi Erick,
I take a look at your source codes and I saw in the getRangeQuery() method
you put a DateFormat as this:
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
...
Date d1 = df.parse(part1);

the last line of code doesnt work with our localed format. for example I put
the '1328/01/01'
and the df.parse(part1) will returns a wrong value that is in Gregorian
format and not Hijri.
I override that method and just remove the try/catch block in which you put
codes with Date stuffs and now it works fine

my overridden method only return new RangeQuery(...);

now Did I make mistake by that?


On 3/5/07, Erick Erickson <[EMAIL PROTECTED]> wrote:

I think you should search the archive for DateTools. There have been
very extensive discussions of this topic that will give you answers
far more quickly.

Dates are strings in Lucene. There's no magic here. You don't need
to override anything to get them to work, all you need to do is make
sure that you index and query for them as searchable strings. For
example, 20070122. If you have different formats for dates, decide
on an underlying format that allows them to be sorted lexically (that
is, by String comparison).

Inspect your index with Luke to see if they're being stored as you
expect. Use QueryParser.toString to see how the query string
is broken up. Don't override anything until you do this or you'll waste
much effort <G>.

Best
Erick


On 3/5/07, Mohammad Norouzi <[EMAIL PROTECTED]> wrote:
>
> Hi
> you know, actually we dont indexed this field as Date. we always use
> string
> instead of Date type because we use both Hijri date and Gregorian date
so
> if
> we put a Hijri date the DateField not work properly. that is why we
index
> such this field as String.
>
> as I read the javadoc for QueryParser, it is said to inherits a class
from
> QueryParser and override its setQueryRange() method. I think in my case
I
> should do it. what do you think?
>
> On 3/5/07, Chris Hostetter <[EMAIL PROTECTED]> wrote:
> >
> >
> > : > I even removed "/" from my query but still not working good.
> > : > Do I have to index dates issues without "/"?
> > : > now in the index I have 1978/05/05 should I change it to 19780505?
> > :
> > : Unless I'm mistaken (and it's been ages since I looked at the date
> stuff
> > : myself) this sort of thing only works if you use DateField to format
> the
> > : field values.
> >
> > correct ... please consult the class level javadocs for the
QUeryParser
> > which talk somewhat extensively about dates in range queries nad using
> > DateField vs DateTools.
> >
> > in general, if searhing on "admitDate:1978/05/05" is working ofr you,
> then
> > a range search with the same format probably won't work for you ...
> > becuase when query parser sees a the range syntax on something that it
> can
> > parse as a date, it's going to expect the indexed format to be in a
very
> > specific format .. you have a lot of control over what format it
> expects,
> > but "1978/05/05" isn't one of them.
> >
> > looking at the query.toString() from the QueryParser result will help
> you
> > understand what it's trying to search on.
> >
> >
> > -Hoss
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Regards,
> Mohammad
>




--
Regards,
Mohammad

Reply via email to