Wie bekommen wir die OCR Texte aus DocuWare ins Topfact Archiv (nach Übernahme auf Dateiebene)?
Migration von OCR Daten / Volltext / Fulltext aus DocuWare zu tfa
1. OCR Daten sammeln durch ArchivMigration Tool
Mit der Option "nur DocuWare Volltextdaten exportieren" ohne Dokumentenarchivierung werden die OCR Daten am Zielsystem in die Tabelle
[topfact6Sync].[dbo].[_Fulltext]
geschrieben. Dies kann einige Zeit dauern.
2. OCR Daten aus _Fulltext Tabell in tfa Volltext übertragen
Vereinfachtes Script
(wenn alle Daten direkt aus der Fulltext-Tabelle übernommen werden sollen. D.h. wenn diese keine Zeilen enthält die bereits im FT übertragen wurden:
INSERT INTO [topfactArchiv_001_FT].[dbo].[tf_Fulltext]
([DocID]
,[FileID]
,[PageIndex]
,[Confidence]
,[ImageWidth]
,[ImageHeight]
,[WordCount]
,[LineCount]
,[DeskewAngle]
,[Fulltext]
,[DateCreated])
SELECT
[TFDocID] as [DocID] --tf_docid
,(SELECT TOP(1) [tf_fileid] FROM [topfactArchiv].[dbo].[tf_Archive001Files] WHERE [tf_docid] = [TFDocID]) as [FileID]
,0 as [PageIndex]
,100 as [Confidence]
,0 as [ImageWidth]
,0 as [ImageHeight]
,0 as [WordCount]
,0 as [LineCount]
,0 as [DeskewAngle]
,[Text]
,GETDATE() as [DateCreated]
FROM [topfactArchiv].[dbo].[_Fulltext]
--WHERE TFDocID = 97700 --debug test
ORDER BY TFDocID ASC
Wichtig: nach Ausführung muss die Tabelle _Fulltext umbenannt werden in _Fulltext_übertragen, damit keine Dopplung entstehen kann
FT Status setzen:
UPDATE
[topfactArchiv].[dbo].[tf_Archive001Files]
SET ft_status = 3, img_status = 3
WHERE tf_fileid IN (
SELECT DISTINCT [FileID] FROM [topfactArchiv_001_FT].[dbo].[tf_Fulltext]
)
Danach muss in der Administration der Volltext-Katalog des Archivs erneut angestoßen werden...
Komplexes Script:
(Achtung, hier ist noch nicht enthalten, dass die Quelldaten ggf. DWDOCID Duplikate aus mehreren Quellarchiven haben könnten)
Mit folgendem Script kann man alle Fulltext Daten übertragen die bisher noch nicht im tfa Volltext enthalten sind.
create table #MissingFTDocuments
(
tf_docid int,
DWDOCID int,
)
INSERT INTO #MissingFTDocuments (tf_docid, DWDOCID)
SELECT
tf_docid,
alte_docid as DWDOCID--, tf_datecreated, tf_usercreated
FROM [topfactArchiv].[dbo].[tf_Archive001]
WHERE tf_docid NOT IN ( --welche sind noch nicht in ft Datenbank enthalten
SELECT DISTINCT
[DocID]
--,[FileID]
FROM [topfactArchiv_001_FT].[dbo].[tf_Fulltext]
)
--SELECT * FROM #MissingFTDocuments;
-- all ft text items which are missing
create table #MissingFTText
(
DWDOCID int,
tf_docid int,
tf_fileid int,
FT varchar(MAX)
)
INSERT INTO #MissingFTText (DWDOCID, tf_docid, tf_fileid, FT)
SELECT
[DocID] as dwdocid -- DW DOCID
,mftd.tf_docid -- tfa tf_docid
,(
SELECT TOP(1) [tf_fileid] FROM [topfactArchiv].[dbo].[tf_Archive001Files]
WHERE [tf_docid] = mftd.tf_docid
) as tf_fileid --die zugehörige FileID
,[Text] --der DW Volltext
FROM [topfact6Sync].[dbo].[_Fulltext] ft
JOIN #MissingFTDocuments mftd
ON ft.DocID = mftd.DWDOCID
--Select * FROM #MissingFTText ORDER BY tf_docid ASC;
Select tf_docid, tf_fileid, FT
FROM #MissingFTText ORDER BY tf_docid ASC;
-- INSERT MissingFTText INTO FT Database...
INSERT INTO [topfactArchiv_001_FT].[dbo].[tf_Fulltext]
([DocID]
,[FileID]
,[PageIndex]
,[Confidence]
,[ImageWidth]
,[ImageHeight]
,[WordCount]
,[LineCount]
,[DeskewAngle]
,[Fulltext]
,[DateCreated])
SELECT
tf_docid as [DocID] --tf_docid
,tf_fileid as [FileID]
,0 as [PageIndex]
,100 as [Confidence]
,0 as [ImageWidth]
,0 as [ImageHeight]
,0 as [WordCount]
,0 as [LineCount]
,0 as [DeskewAngle]
,FT
,GETDATE() as [DateCreated]
FROM #MissingFTText ORDER BY tf_docid ASC;
---- update files with ft_status
--SELECT [tf_fileid]
-- ,[tf_docid]
-- ,[img_status]
-- ,[ft_status]
-- FROM
UPDATE
[topfactArchiv].[dbo].[tf_Archive001Files]
SET ft_status = 3, img_status = 3
WHERE tf_fileid IN (
Select DISTINCT tf_fileid FROM #MissingFTText
)
If(OBJECT_ID('tempdb..#MissingFTDocuments') Is Not Null)
Begin
Drop Table #MissingFTDocuments
End
If(OBJECT_ID('tempdb..#MissingFTText') Is Not Null)
Begin
Drop Table #MissingFTText
End
3. Volltextstatus zurücksetzen
Für alle Dokumente die nicht übertragen wurden. diese muss der Image und OCR Server nochmal manuell verarbeiten
update f
set img_status = 0, ft_status = 0
FROM [topfactArchiv].[dbo].[tf_Archive001Files] as f
where f.tf_fileid not in
(
select fileid from topfactArchiv_001_FT.dbo.tf_Fulltext
)
4. Prüfen
Wie viele Dokumente sind vorhanden die noch nicht in der Volltexttabelle sind?
Das Ergebnis sollte 0 oder wenige duzend sein, die vom OCR Server verarbeitet werden...
SELECT
tf_docid,
alte_docid as DWDOCID--, tf_datecreated, tf_usercreated
FROM [topfactArchiv].[dbo].[tf_Archive001]
WHERE tf_docid NOT IN ( --welche sind noch nicht in ft Datenbank enthalten
SELECT DISTINCT
[DocID]
--,[FileID]
FROM [topfactArchiv_001_FT].[dbo].[tf_Fulltext]
)