Use Index#highlight with custom key instead of doc_id


I’d like to highlight matching content of a document for a given query.
I use
index.highlight(query, doc_id,
:field => :content, :excerpt_length => :all,
:pre_tag => “<<”, :post_tag => “>>”
for this. Problem is, I defined my index with a :key => some_hash, and
I’d like to give index.highlight query and some_hash as parameters,
since I have no idea what doc_id is for a given LazyDoc.

Is there a way to retrieve doc_id from a LazyDoc?
Would that be possible to provide index#highlight with a custom key
instead of doc_id?

As a work-around I retrieve doc_id like this:,some_hash)).hits.first.doc
which I suppose isn’t really optimal.

Any suggestion would be greatly appreciated!

Thanks in advance,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs