lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: TermRangeQuery
Date Sun, 28 Nov 2010 18:19:58 GMT
Why won't Ian's suggestion work? You haven't really given us a clue what it
is about
your attempt that didn't work. The expected and actual output would be
useful...

But Ian's notion is the well-known issue that lexical and numeric sorting
aren't
at all the same. You'd get reasonable results if you left-padded the number
portion of the IDs with 0 out to 4 spaces, thus
aa-90   -> aa-0090
aa-123 -> aa-0123
aa-1000 > aa-1000

and your range queries should work. You might have to transform them
back when displayed. Or you could add them to your document twice.
Once in a "hidden" field, the one you searched against in your range query
and the other to display. This latter wouldn't bloat your index (much) since
you would store one and index the other....

Best
Erick

On Fri, Nov 26, 2010 at 5:01 PM, Amin Mohammed-Coleman <aminmc@gmail.com>wrote:

> Essentially I'd like to construct a query which is almost like SQL in
> clause.  The lucene document contains the id and a string value. I'd like to
> get the string value based on the id key.  The ids may range within 1000. Is
> this possible to do?
>
> Thanks
> Amin
>
> Sent from my iPhone
>
> On 26 Nov 2010, at 20:18, Ian Lea <ian.lea@gmail.com> wrote:
>
> > What sort of ranges are you trying to use?  Maybe you could store a
> > separate field, just for these queries, with some normalized form of
> > the ids, with all numbers padded out to the same length etc.
> >
> > --
> > Ian.
> >
> > On Fri, Nov 26, 2010 at 4:34 PM, Amin Mohammed-Coleman <aminmc@gmail.com>
> wrote:
> >> Hi
> >>
> >> Unfortunately my range query approach did not work.   It seems to be
> related to the ids themselves.  The list has ids that look this:
> >>
> >>
> >> ID-NYC-1234
> >> ID-LND-1234
> >> TX-NYC-1334
> >> TX-NYC-BBC-123
> >>
> >> The ids may range from 90 to 1000.  Is there another approach I could
> take?  I tried building a string with all the ids and set them against a
> field for example:
> >>
> >> dataId: ID-NYC-123 dataId: ID-NYC-1234....
> >>
> >> but that's not a great approach I know...
> >>
> >> any help would be appreciated.
> >>
> >> Thanks
> >> Amin
> >>
> >>
> >>
> >> On 26 Nov 2010, at 14:39, Ian Lea wrote:
> >>
> >>> Absolutely, as long as your ids will sort as you expect.
> >>>
> >>> I'm not clear what you mean by XDF-123 but if you've got
> >>>
> >>> AAA-123
> >>> AAA-124
> >>> ...
> >>> ABC-123
> >>> ABC-234
> >>> etc.
> >>>
> >>> then you'll be fine.  If they don't sort so neatly you can use the
> >>> TermRangeQuery constructor that takes a Collator but note the
> >>> performance warning in the javadocs.
> >>>
> >>>
> >>> --
> >>> Ian.
> >>>
> >>>
> >>> On Fri, Nov 26, 2010 at 2:18 PM, Amin Mohammed-Coleman <
> aminmc@gmail.com> wrote:
> >>>> Hi All
> >>>>
> >>>> I was wondering whether I can use TermRangeQuery for my use case.  I
> have a collection of ids (represented as XDF-123) and I would like to do a
> search for all the ids (might be in the range of 10000) and for each
> matching id I want to get the corresponding data that is stored in the index
> (for example the document contains id and string value).  I am using a
> custom collector to collect that string value for each match.  Is it ok to
> use a TermRangeQuery for the ids rather than creating a massive query
> string?
> >>>>
> >>>>
> >>>> Thanks
> >>>> Amin
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >>>> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>>>
> >>>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >>> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message