You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Kristjan Siimson <kr...@gmail.com> on 2010/04/14 21:15:33 UTC

Indexing lists of IDs

Hello,

I have document for which I'd like to index an array of indexes. For
example, there is a product that belongs to categories with IDs 12, 15, 16,
145, 148. I'd like to index these categories, and then be able to use them
in queries, so that I can search for product which's name is "Bottle" and
which belongs to category 12.

I came up with creating a field in which I store the ID numbers and separate
them with spaces. However, when I tried to create a term query, the query
never gave any results. Can anybody help me with this?

Sincerely,
Kristjan Siimson

Re: Indexing lists of IDs

Posted by Kristjan Siimson <kr...@gmail.com>.
Thanks, the problem was with tokenizer, which didn't index any numbers, so I
tried writing my own, and it works perfectly! :)

Sincerely,
Kristjan Siimson

On Wed, Apr 14, 2010 at 2:12 PM, Uwe Schindler <uw...@thetaphi.de> wrote:

> You can add the terms with Field.Index.NOT_ANALYZED multiple times to the
> same field. If you use an analyzer like WhitespaceAnalyzer and you analyze
> your tersm, you must also pass the analyzed term through analyzer when
> building a TermQuery. This may explain, why you don’t get those IDs.
>
> But for IDs in general, you should not use analyzers and add as
> NOT_ANYLYZED and query with TermQuery. As explained before, just add more
> than one term to the same field.
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: Kristjan Siimson [mailto:kristjan.siimson@gmail.com]
> > Sent: Wednesday, April 14, 2010 9:16 PM
> > To: java-user@lucene.apache.org
> > Subject: Indexing lists of IDs
> >
> > Hello,
> >
> > I have document for which I'd like to index an array of indexes. For
> > example, there is a product that belongs to categories with IDs 12, 15,
> > 16,
> > 145, 148. I'd like to index these categories, and then be able to use
> > them
> > in queries, so that I can search for product which's name is "Bottle"
> > and
> > which belongs to category 12.
> >
> > I came up with creating a field in which I store the ID numbers and
> > separate
> > them with spaces. However, when I tried to create a term query, the
> > query
> > never gave any results. Can anybody help me with this?
> >
> > Sincerely,
> > Kristjan Siimson
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

RE: Indexing lists of IDs

Posted by Uwe Schindler <uw...@thetaphi.de>.
You can add the terms with Field.Index.NOT_ANALYZED multiple times to the same field. If you use an analyzer like WhitespaceAnalyzer and you analyze your tersm, you must also pass the analyzed term through analyzer when building a TermQuery. This may explain, why you don’t get those IDs.

But for IDs in general, you should not use analyzers and add as NOT_ANYLYZED and query with TermQuery. As explained before, just add more than one term to the same field.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Kristjan Siimson [mailto:kristjan.siimson@gmail.com]
> Sent: Wednesday, April 14, 2010 9:16 PM
> To: java-user@lucene.apache.org
> Subject: Indexing lists of IDs
> 
> Hello,
> 
> I have document for which I'd like to index an array of indexes. For
> example, there is a product that belongs to categories with IDs 12, 15,
> 16,
> 145, 148. I'd like to index these categories, and then be able to use
> them
> in queries, so that I can search for product which's name is "Bottle"
> and
> which belongs to category 12.
> 
> I came up with creating a field in which I store the ID numbers and
> separate
> them with spaces. However, when I tried to create a term query, the
> query
> never gave any results. Can anybody help me with this?
> 
> Sincerely,
> Kristjan Siimson


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Indexing lists of IDs

Posted by Rene Hackl-Sommer <re...@gmx.de>.
Hi Kristjan,

which Tokenizer and Filters are you using for the ID field?

Rene

Am 14.04.2010 21:15, schrieb Kristjan Siimson:
> Hello,
>
> I have document for which I'd like to index an array of indexes. For
> example, there is a product that belongs to categories with IDs 12, 15, 16,
> 145, 148. I'd like to index these categories, and then be able to use them
> in queries, so that I can search for product which's name is "Bottle" and
> which belongs to category 12.
>
> I came up with creating a field in which I store the ID numbers and separate
> them with spaces. However, when I tried to create a term query, the query
> never gave any results. Can anybody help me with this?
>
> Sincerely,
> Kristjan Siimson
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org