Comments (2)
@nickprock In Haystack 2.0, you can just set the id of the document. So you could have a custom component in an indexing pipeline just before the DocumentWriter or you could create a wrapper around one of the other components, such as a FileConverter.
A component could look like the following
from copy import deepcopy
from typing import List
from haystack import Document, component
@component
class DocumentIDCreator:
# This is a pass-through component that returns the same Documents but with different ids
@component.output_types(documents=List[Document])
def run(self, documents: List[Document]):
updated_documents = []
for doc in documents:
id = calculate_id(doc, id_hash_keys) # using your code above
updated_documents.append(Document(id=id, content=doc.content, meta=deepcopy(doc.meta), embedding=doc.embedding))
return {"documents": updated_documents}
Please let us know whether that can solve your problem so that we can close the issue. 🙂
from haystack.
Thanks @julian-risch
from haystack.
Related Issues (20)
- Hybrid doc search e2e fails with DuplicateDocumentError
- `AzureOpenAIGenerator` not passing `meta` (used tokens, model...) to Langfuse
- Error Transcribing Audio: [WinError 2] The system cannot find the file specified
- [V2.2.0] ChatPromptBuilder is not export HOT 1
- feat: Port (and upgrade) DocxToDocument converter from Haystack v1
- feat: Port PptxToDocument converter from Haystack v1
- Update the Get Started page on the Haystack website
- `ContextRelevanceEvaluator`: statements extraction can be made more robust
- Error while loading pipelines from yaml files HOT 2
- docs: Create docs page for `TransformerTextRouter`
- Cannot specify model version for `SentenceTransformer` embedding retriever HOT 1
- Milvus Exception error
- SQuAD to DPR conversion script missing in the repo HOT 2
- `@component` decorator on a class that inherits from another marked with the same breaks its init
- Test the evaluation harness on RAG parameter tuning
- Benchmark hyde using evaluation harness
- docs: Add docs for `PPTXToDocument` converter
- `DocumentSplitter` - `split_by="page"` is not documented
- `EvaluationRunResult.score_result()` is not documented in API reference
- 'PydanticWriter' and 'PydanticReader' components for type-safe object storage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haystack.