Replies: 1 comment 6 replies
-
Hey @kaumanns sorry for the late reply. I'm not too sure what was your final goal but I think it was to filter the results by language? Did you have a look at https://docs.haystack.deepset.ai/docs/metadata_filtering? It might be way easier than this and require no hacking of the source. If that's not sufficient, let's rather have an elegant solution added to Haystack! PRs are always welcome 😊 |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
SOLVED (probably, not thoroughly tested, but works for now for me)
Goal: Extend the query with language detection in order to filter the retriever results by document metadata (see https://docs.haystack.deepset.ai/docs/metadata_filtering).
Solution: Add a custom node in the pipeline (see
LanguageDetectorNode
in the discussion above), as documented here: https://docs.haystack.deepset.ai/docs/custom_nodes. Also modifyRetrieverBase
.This solution hacks on the original source code. It is probably more elegant to subclass your preferred retriever class.
See also discussion in #3475
Pipeline definition:
Custom node:
Note the '_meta' field in the return dictionary from
run()
. (The field name is arbitrary.) This dictionary must be referenced by therun()
function inhaystack.nodes.retriever.base.BaseRetriever
as follows:Both filters from query and the prior node are joined. The query filters overwrite the prior node filters.
This solution can be applied to e.g. entity extraction as well.
Beta Was this translation helpful? Give feedback.
All reactions