Technik, Gothic und Anderes

Technik ist Spiel, Gothic ist ernst und Zeit hat man zuviel

Excel und Powerpoint mit htdig indizieren

Geschrieben von skaldrom am 27. March 2007

Möchte man xls und ppt in den Index der Intranet Suchengine htdig aufnehmen, muss man etwas Magie wirken lassen:

  1. Es braucht ein Umwandler “gewünscht2txt”. Ich habe xls2csv für Excel und catppt für Powerpoint gewählt.
  2. Die Mimetypes sollten aktualisiert werden. /etc/htdig/mime.types:
    [...]
    application/vnd.ms-excel        xls
    application/vnd.ms-powerpoint   ppt
    [...]
  3. Externe Parser müssen aktiviert werden in /etc/htdig/htdig.conf:
    [...]
    external_parsers: application/msword /usr/share/htdig/parse_doc.pl \
    application/postscript /usr/share/htdig/parse_doc.pl \
    application/pdf /usr/share/htdig/parse_doc.pl \
    application/vnd.ms-powerpoint /usr/share/htdig/parse_doc.pl \
    application/vnd.ms-excel /usr/share/htdig/parse_doc.pl
    [...]
  4. Nun muss noch /usr/share/htdig/parse_doc.pl angepasst werden:
    [...]
    #
    # Excel
    #
    $XLS2CSV = "/usr/bin/xls2csv";#
    # Powerpoint
    #
    $CATPPT = "/usr/bin/catppt";
    [...]
    } elsif ( $ARGV[1] =~  /excel/) {       # it's MS Excel - this detection is a kludge
        $parser = $XLS2CSV;
        # convert all possible sheets to ascii
        $parsecmd = "$parser \"$ARGV[0]\" |";
        $type = "MS-Excel";
        $dehyphenate = 0;               # Excel documents not likely hyphenated
    } elsif ( $ARGV[1] =~  /powerpoint/) {
        $parser = $CATPPT;
        # convert all possible sheets to ascii
        $parsecmd = "$parser \"$ARGV[0]\" |";
        $type = "MS-Powerpoint";
        $dehyphenate = 0;
    }
    [...]
  5. Nun sollts funzen.

Man könnte es wohl auch über html machen (mit dem Helfer xlhtml). Dazu müsste die Zeile in htdig.conf heissen:

application/vnd.ms-excel->text/html /usr/share/htdig/parse_doc.pl

und dann müsste inparse_doc.pl xlhtml mit den korrekten Parametern aufgerufen werden.

Generell können folgende Probleme auftreten:

Apache Index:
Indiziert man Verzeichnisse, die das Apache Index Modul erzeugt (Dateibaum ohne index.html), so können Seiten mehrfach gespeichert sein weil sich die Parameter unterscheiden. Um dies zu verhindern muss htdig.conf ergänzt werden:

bad_querystr: ?C=D ?C=S ?C=M ?C=N ?O=A ?D=A ?D=D ?M=A ?M=D ?N=A ?N=D ?S=A ?S=D C=D C=S C=M C=N O=A D=A D=D M=A M=D N=A N=D S=A S=D

Ghostscript-Hanger:
Mein Indexer hatte die Tendenz beim Aufruf von gs zu hangen. Nundenn, ein Umstellen von “pstotext” auf “pdftotext” hat das ganze subjektiv schneller gemacht und bis jetzt ist es nimmer gestalled. In /usr/share/htdig/parse_doc.pl:

[...]
#
# set this to your PDF to text converter
#
#$CATPDF = "/usr/bin/pstotext";                         # From "pstotext"
$CATPDF = "/usr/bin/pdftotext";                         # From "pdftotext"
if (! -x $CATPDF) { $CATPDF = "/usr/bin/pdftotext"; }   # From "xpdf"/"xpdf-i"
if (! -x $CATPDF) { $CATPDF = "/usr/bin/ps2ascii"; }    # From a ghostscript
if (! -x $CATPDF) { $CATPDF = "/bin/true"; }
[...]
Teile und geniesse:
  • Technorati
  • del.icio.us
  • MisterWong
  • Digg
  • StumbleUpon
  • blogmarks
  • Furl
  • Simpy
  • Spurl
  • YahooMyWeb


Lassen Sie eine Antwort hier...

XHTML: Sie können folgende Tags verwenden: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>