django-watson icon indicating copy to clipboard operation
django-watson copied to clipboard

expose metadata also in .filter() results

Open valentijnscholten opened this issue 3 years ago • 3 comments

Currently when using .search() you can access the metadata of each searchresult using result.meta['xxxx'] or result.meta.xxxx.

When using .filter() on en existing queryset, this metadata is not exposed. Would be helpful to access the metadata here as it could contain data not available in the queryset models or the result of some expensive calculation performed during indexing.

valentijnscholten avatar Sep 15 '20 13:09 valentijnscholten

I don't think this is possible. If you want the metadata, why not use search()?

On Tue, 15 Sep 2020 at 14:39, valentijnscholten [email protected] wrote:

Currently when using .search() you can access the metadata of each searchresult using result.meta['xxxx'] or result.meta.xxxx.

When using .filter() on en existing queryset, this metadata is not exposed. Would be helpful to access the metadata here as it could contain data not available in the queryset models or the result of some expensive calculation performed during indexing.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/etianen/django-watson/issues/279, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEKCCGGU6RIZ536DOH6GDSF5U7BANCNFSM4RNE2SOQ .

etianen avatar Sep 15 '20 16:09 etianen

the watson_rank is exposed, so meta could be exposed to (as dictionary)?

I need to perform some filtering and prefetching before performing the full text search.

valentijnscholten avatar Sep 15 '20 17:09 valentijnscholten

The metadata is saved as a json-encoded blob. It could possibly be attached to the model using ".annotate()", but it would be attached as a string, rather than a dictionary. I can't see a way to improve on this.

On Tue, 15 Sep 2020 at 18:03, valentijnscholten [email protected] wrote:

the watson_rank is exposed, so meta could be exposed to (as dictionary)?

I need to perform some filtering and prefetching before performing the full text search.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/etianen/django-watson/issues/279#issuecomment-692847737, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEKCG6H6VGCOFRHT5YMGDSF6M5ZANCNFSM4RNE2SOQ .

etianen avatar Sep 17 '20 14:09 etianen