You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Prav Buz <bu...@gmail.com> on 2011/03/11 10:02:59 UTC

Getting Category ID (primary key)

Hi,

I need to show a facets on Category and then I need the category id in the
href link. For this what I 'm trying to do is create a field which will
store ID|Category in the schema and split it in the UI.
Also I have Category and category id 's indexed .

Categories are multivalued as well, means there will be more than one
category for one document.


Is there any better way to do this? Has anyone gone thru this before?

Thanks

Praveen

Re: Getting Category ID (primary key)

Posted by Chris Hostetter <ho...@fucit.org>.
: If it works, it's performant and not too messy it's a good way :-) . You can
: also consider just faceting on Id, and use the id to fetch the categoryname
: through sql / nosql.
: That way your logic is seperated from your presentation, which makes
: extending (think internationalizing, etc.) easier. Not sure if that's
: appropriate for your 'category' field but anyway.

That's the advice i generally give *if* you already have access to the 
system of record for your categorization in your application (if not, the 
tradeoff of the extra data lookup may not be worth the cost in 
flexibility)

>From the notes in my "Many Facets" talk (slide #24: "Pretty" 
facet.field Terms)...

>> If you can use unique identifiers (instead of pretty, long, string 
>> labels) it can reduce the memory and simplify the request parsing (see 
>> next Tip) but it adds work to your front end application -- keeping 
>> track of the mapping between id => pretty label. If your application 
>> already needs to knows about these mappsings for other purposes, then 
>> it's much simpler to take advantage of that.

	http://people.apache.org/~hossman/apachecon2010/facets/



-Hoss

Re: Getting Category ID (primary key)

Posted by Prav Buz <bu...@gmail.com>.
Hi,

Thanks for your suggestions, thanks to the great community too :)

regards
Praveen

On Fri, Mar 11, 2011 at 11:01 PM, Geert-Jan Brits <gb...@gmail.com> wrote:

> If it works, it's performant and not too messy it's a good way :-) . You
> can
> also consider just faceting on Id, and use the id to fetch the categoryname
> through sql / nosql.
> That way your logic is seperated from your presentation, which makes
> extending (think internationalizing, etc.) easier. Not sure if that's
> appropriate for your 'category' field but anyway.
>
> I belief you were asking this because you already had 2 multivalued fields:
>  'id' and 'category' which you wanted to reuse for this particular
> use-case.
> In short: you can't link a particular value in a multivalued field (e.g:
> 'id') to a particular value in another multivalued field (e.g: 'category'),
> so just give up this route, and go with what you had, or use the suggested
> above.
>
> hth,
> Geert-Jan
>
>
>
> 2011/3/11 Prav Buz <bu...@gmail.com>
>
> > Hi,
> > Thanks Erik, yes that's what I've done for now, but was wondering if it's
> > the best way :)
> >
> > thanks
> >
> > Praveen
> >
> > On Fri, Mar 11, 2011 at 6:06 PM, Erick Erickson <erickerickson@gmail.com
> > >wrote:
> >
> > > Thinking out loud here, but would it work to just have ugly
> > > categories? Instead of splitting them up, just encode them like
> > > 1|a
> > > 2|b
> > > 3|c
> > >
> > > or some such. Then split them  back up again and display
> > > the name to the user and use the ID in the URL....
> > >
> > > Best
> > > Erick
> > >
> > > On Fri, Mar 11, 2011 at 4:17 AM, Prav Buz <bu...@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > Yes I already have different fields for category and category Id ,
> and
> > > they
> > > > are in same order when retrieved from solr
> > > >
> > > > for eg:
> > > > IDs
> > > > 1
> > > > 3
> > > > 4
> > > > 5
> > > > names
> > > > a
> > > > b
> > > > c
> > > > d
> > > > e
> > > >
> > > > id 1 is of name a and id 5 is of name e. but when I sort the category
> > > names
> > > > , looses this order as they are not related in any manner in the solr
> > > docs.
> > > >
> > > >
> > > > Thanks
> > > >
> > > > Praveen
> > > >
> > > > On Fri, Mar 11, 2011 at 2:35 PM, Gora Mohanty <go...@mimirtech.com>
> > > wrote:
> > > >
> > > >> On Fri, Mar 11, 2011 at 2:32 PM, Prav Buz <bu...@gmail.com>
> wrote:
> > > >> [...]
> > > >> > I need to show a facets on Category and then I need the category
> id
> > in
> > > >> the
> > > >> > href link. For this what I 'm trying to do is create a field which
> > > will
> > > >> > store ID|Category in the schema and split it in the UI.
> > > >> > Also I have Category and category id 's indexed .
> > > >> [...]
> > > >>
> > > >> Why not have two different fields for category, and for category ID?
> > > >>
> > > >> Regards,
> > > >> Gora
> > > >>
> > > >
> > >
> >
>

Re: Getting Category ID (primary key)

Posted by Geert-Jan Brits <gb...@gmail.com>.
If it works, it's performant and not too messy it's a good way :-) . You can
also consider just faceting on Id, and use the id to fetch the categoryname
through sql / nosql.
That way your logic is seperated from your presentation, which makes
extending (think internationalizing, etc.) easier. Not sure if that's
appropriate for your 'category' field but anyway.

I belief you were asking this because you already had 2 multivalued fields:
 'id' and 'category' which you wanted to reuse for this particular use-case.
In short: you can't link a particular value in a multivalued field (e.g:
'id') to a particular value in another multivalued field (e.g: 'category'),
so just give up this route, and go with what you had, or use the suggested
above.

hth,
Geert-Jan



2011/3/11 Prav Buz <bu...@gmail.com>

> Hi,
> Thanks Erik, yes that's what I've done for now, but was wondering if it's
> the best way :)
>
> thanks
>
> Praveen
>
> On Fri, Mar 11, 2011 at 6:06 PM, Erick Erickson <erickerickson@gmail.com
> >wrote:
>
> > Thinking out loud here, but would it work to just have ugly
> > categories? Instead of splitting them up, just encode them like
> > 1|a
> > 2|b
> > 3|c
> >
> > or some such. Then split them  back up again and display
> > the name to the user and use the ID in the URL....
> >
> > Best
> > Erick
> >
> > On Fri, Mar 11, 2011 at 4:17 AM, Prav Buz <bu...@gmail.com> wrote:
> > > Hi,
> > >
> > > Yes I already have different fields for category and category Id , and
> > they
> > > are in same order when retrieved from solr
> > >
> > > for eg:
> > > IDs
> > > 1
> > > 3
> > > 4
> > > 5
> > > names
> > > a
> > > b
> > > c
> > > d
> > > e
> > >
> > > id 1 is of name a and id 5 is of name e. but when I sort the category
> > names
> > > , looses this order as they are not related in any manner in the solr
> > docs.
> > >
> > >
> > > Thanks
> > >
> > > Praveen
> > >
> > > On Fri, Mar 11, 2011 at 2:35 PM, Gora Mohanty <go...@mimirtech.com>
> > wrote:
> > >
> > >> On Fri, Mar 11, 2011 at 2:32 PM, Prav Buz <bu...@gmail.com> wrote:
> > >> [...]
> > >> > I need to show a facets on Category and then I need the category id
> in
> > >> the
> > >> > href link. For this what I 'm trying to do is create a field which
> > will
> > >> > store ID|Category in the schema and split it in the UI.
> > >> > Also I have Category and category id 's indexed .
> > >> [...]
> > >>
> > >> Why not have two different fields for category, and for category ID?
> > >>
> > >> Regards,
> > >> Gora
> > >>
> > >
> >
>

Re: Getting Category ID (primary key)

Posted by Prav Buz <bu...@gmail.com>.
Hi,
Thanks Erik, yes that's what I've done for now, but was wondering if it's
the best way :)

thanks

Praveen

On Fri, Mar 11, 2011 at 6:06 PM, Erick Erickson <er...@gmail.com>wrote:

> Thinking out loud here, but would it work to just have ugly
> categories? Instead of splitting them up, just encode them like
> 1|a
> 2|b
> 3|c
>
> or some such. Then split them  back up again and display
> the name to the user and use the ID in the URL....
>
> Best
> Erick
>
> On Fri, Mar 11, 2011 at 4:17 AM, Prav Buz <bu...@gmail.com> wrote:
> > Hi,
> >
> > Yes I already have different fields for category and category Id , and
> they
> > are in same order when retrieved from solr
> >
> > for eg:
> > IDs
> > 1
> > 3
> > 4
> > 5
> > names
> > a
> > b
> > c
> > d
> > e
> >
> > id 1 is of name a and id 5 is of name e. but when I sort the category
> names
> > , looses this order as they are not related in any manner in the solr
> docs.
> >
> >
> > Thanks
> >
> > Praveen
> >
> > On Fri, Mar 11, 2011 at 2:35 PM, Gora Mohanty <go...@mimirtech.com>
> wrote:
> >
> >> On Fri, Mar 11, 2011 at 2:32 PM, Prav Buz <bu...@gmail.com> wrote:
> >> [...]
> >> > I need to show a facets on Category and then I need the category id in
> >> the
> >> > href link. For this what I 'm trying to do is create a field which
> will
> >> > store ID|Category in the schema and split it in the UI.
> >> > Also I have Category and category id 's indexed .
> >> [...]
> >>
> >> Why not have two different fields for category, and for category ID?
> >>
> >> Regards,
> >> Gora
> >>
> >
>

Re: Getting Category ID (primary key)

Posted by Erick Erickson <er...@gmail.com>.
Thinking out loud here, but would it work to just have ugly
categories? Instead of splitting them up, just encode them like
1|a
2|b
3|c

or some such. Then split them  back up again and display
the name to the user and use the ID in the URL....

Best
Erick

On Fri, Mar 11, 2011 at 4:17 AM, Prav Buz <bu...@gmail.com> wrote:
> Hi,
>
> Yes I already have different fields for category and category Id , and they
> are in same order when retrieved from solr
>
> for eg:
> IDs
> 1
> 3
> 4
> 5
> names
> a
> b
> c
> d
> e
>
> id 1 is of name a and id 5 is of name e. but when I sort the category names
> , looses this order as they are not related in any manner in the solr docs.
>
>
> Thanks
>
> Praveen
>
> On Fri, Mar 11, 2011 at 2:35 PM, Gora Mohanty <go...@mimirtech.com> wrote:
>
>> On Fri, Mar 11, 2011 at 2:32 PM, Prav Buz <bu...@gmail.com> wrote:
>> [...]
>> > I need to show a facets on Category and then I need the category id in
>> the
>> > href link. For this what I 'm trying to do is create a field which will
>> > store ID|Category in the schema and split it in the UI.
>> > Also I have Category and category id 's indexed .
>> [...]
>>
>> Why not have two different fields for category, and for category ID?
>>
>> Regards,
>> Gora
>>
>

Re: Getting Category ID (primary key)

Posted by Prav Buz <bu...@gmail.com>.
Hi,

Yes I already have different fields for category and category Id , and they
are in same order when retrieved from solr

for eg:
IDs
1
3
4
5
names
a
b
c
d
e

id 1 is of name a and id 5 is of name e. but when I sort the category names
, looses this order as they are not related in any manner in the solr docs.


Thanks

Praveen

On Fri, Mar 11, 2011 at 2:35 PM, Gora Mohanty <go...@mimirtech.com> wrote:

> On Fri, Mar 11, 2011 at 2:32 PM, Prav Buz <bu...@gmail.com> wrote:
> [...]
> > I need to show a facets on Category and then I need the category id in
> the
> > href link. For this what I 'm trying to do is create a field which will
> > store ID|Category in the schema and split it in the UI.
> > Also I have Category and category id 's indexed .
> [...]
>
> Why not have two different fields for category, and for category ID?
>
> Regards,
> Gora
>

Re: Getting Category ID (primary key)

Posted by Gora Mohanty <go...@mimirtech.com>.
On Fri, Mar 11, 2011 at 2:32 PM, Prav Buz <bu...@gmail.com> wrote:
[...]
> I need to show a facets on Category and then I need the category id in the
> href link. For this what I 'm trying to do is create a field which will
> store ID|Category in the schema and split it in the UI.
> Also I have Category and category id 's indexed .
[...]

Why not have two different fields for category, and for category ID?

Regards,
Gora