etianen / django-watson

Full-text multi-table search application for Django. Easy to install and use, with good performance.
BSD 3-Clause "New" or "Revised" License
1.2k stars 129 forks source link

expose metadata also in .filter() results #279

Open valentijnscholten opened 3 years ago

valentijnscholten commented 3 years ago

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.

etianen commented 3 years ago

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 notifications@github.com 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 .

valentijnscholten commented 3 years ago

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.

etianen commented 3 years ago

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 notifications@github.com 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 .