On Mon, Jan 22, 2007 at 07:29:08PM +0700, Stian Haklev
wrote:> Hi everyone, thank you for the help last time.
>
> A quick question, through rereading the ferret tutorial I realized
> that by adding :key => :id to the index loading, I could access my
> documents through index["11"], in addition to using the doc_id
from
> ferret through index[122]... This is great, and saves me a line or two
> a lot of places in my code. However, is there a way of extracting the
> doc_id from an object you find like this. Ie I want to know the doc_id
> for document index["11"]. The reason for this is that I need the
> doc_id for the highlight function (this won''t work based only on a
> document key will it?)
by definition your key field has to be unique just like a primary key in
a database. So I think the easiest way to retrieve the doc_id for key
''11'' is to run a search for ''key:11''.
However that might not be what you
want since you would end up querying again for the record you already
have found.
Instead, the Index class should store the document id in the returned
LazyDoc instance, which is not possible atm, imho.
cheers,
Jens
--
webit! Gesellschaft f?r neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de
Schnorrstra?e 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66