lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <mar...@rectangular.com>
Subject Re: [lucy-user] Getting matched query terms for HitDocs
Date Fri, 30 Aug 2013 19:55:10 GMT
On Thu, Aug 29, 2013 at 11:16 PM, Philip Southam <philip@zefr.com> wrote:
> Thanks Peter. I've gotten as far as getting a value out of
> LUCY_Compiler_Highlight_Spans. Now the part I'm struggling with is
> unmarshalling the data out of the returned spans cfish_VArray* object.
> In lines 141-148 of this gist[1] I've done my best to port the perl
> example referenced in the markmail link. It compiles and runs, but
> instead of printing (line 148) what I would expect to be a matching
> term, I get something like:
>
>         Lucy::Search::Span@0x00000000026fec90
>
> indicating I'm not interacting with the spans object returned on line
> 143 properly. Anyone have any suggestions?
>
>
> [1]: https://gist.github.com/philipsoutham/6386741

That's the default To_String() method, which is inherited by
Lucy::Search::Span from Clownfish::Object.  (For the implementation, see
`Obj_To_String_IMP` clownfish/runtime/core/Clownfish/Obj.c.)  Since Span
doesn't have its own stringification routine, you'll need to extract the data
you want using its accesssors, whose fully qualified names are
`LUCY_Span_Get_Offset`, `LUCY_Span_Get_Length` and `LUCY_Span_Get_Weight`.

Those methods are declared in core/Lucy/Search/Span.cfh (here's one)...

    /** Accessor for <code>offset</code> attribute.
     */
    public int32_t
    Get_Offset(Span *self);

... and implemented in core/Lucy/Search/Span.c:

    int32_t
    Span_Get_Offset_IMP(Span *self) {
        return Span_IVARS(self)->offset;
    }

HTH,

Marvin Humphrey

Mime
View raw message