• Solr client on VMS

    From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to All on Fri Dec 6 19:49:44 2024
    I have been looking a bit at Solr recently. For those that don't
    know Solr, then it is a text search engine - or more accurate it
    is a web frontend for the Lucene text search engine. Both
    Solr and Lucene are Apache projects (open source).

    Solr is basically exposing a web API, so anything that can do
    HTTP POST can use Solr. But clients encapsulating the HTTP
    stuff does exist for many languages. On VMS then both JVM languages
    and Python should be able to use a standard client.

    But there are also the traditional languages. Maybe it could
    be nice to be able to access Solr from one of those. VMS Pascal
    is actually a very nice language, so I picked that. And I could
    reuse some stuff I had on the shelf.

    pSolr (Pascal)-|->phttp (Pascal)->vms_http (C)->vms_socket (C)->sockets
    |->pJSON (Pascal)->cJSON (C, not written by me)

    Demo:

    $ type load.pas
    [inherit('common','pSolr')]
    program load(input,output);

    var
    solr : solr_ctxptr;

    begin
    solr := psolr_setup('arnepc5', 8888, 'chessopening');
    psolr_delete(solr, '*:*');
    psolr_insert(solr, 1, 'names', 'Spanish defense, Ruy Lopez',
    'moves', '1. e4, e5, 2. Nf3, Nc6, 3. Bb5,');
    psolr_insert(solr, 2, 'names', 'French defense', 'moves', '1. e4,
    e6, 2. d4, d5,');
    psolr_insert(solr, 3, 'names', 'Sicilian defense', 'moves', '1. e4,
    c5,');
    psolr_insert(solr, 4, 'names', 'Queens gambit', 'moves', '1. d4, d5,
    2. c4,');
    psolr_insert(solr, 5, 'names', 'Dutch defense', 'moves', 'd4, f5,');
    psolr_insert(solr, 6, 'names', 'Reti opening', 'moves', 'Nf3, d5, 2.
    c4,');
    end.
    $ pas load
    $ link load + psolr/libr
    $ run load
    $ type search.pas
    [inherit('common','pSolr')]
    program search(input,output);

    procedure dump(solr : solr_ctxptr; query : pstr);

    var
    res : solr_query_res;
    i : integer;

    begin
    writeln('search for : ' + query);
    res := psolr_query_df(solr, query, 'alltext');
    for i := 1 to psolr_hits(res) do begin
    writeln(' ', psolr_get_field(res, i-1, 'names'), ' - ', psolr_get_field(res, i-1, 'moves'));
    end;
    end;

    var
    solr : solr_ctxptr;

    begin
    solr := psolr_setup('arnepc5', 8888, 'chessopening');
    (* all *)
    dump(solr, '*:*');
    (* one *)
    dump(solr, 'names:defense');
    dump(solr, 'moves:d4');
    (* dual *)
    dump(solr, 'alltext:defense');
    dump(solr, 'alltext:d4');
    dump(solr, 'defense'); (* default field *)
    dump(solr, 'd4'); (* default field *)
    (* boolean *)
    dump(solr, 'names:defense moves:d4'); (* implicit or *)
    dump(solr, 'names:defense AND moves:d4'); (* and *)
    dump(solr, 'names:defense NOT moves:d4'); (* not *)
    dump(solr, 'defense d4'); (* default field + implicit or *)
    dump(solr, 'defense AND d4'); (* default field + and *)
    dump(solr, 'defense NOT d4'); (* default field + not *)
    (* wildcard *)
    dump(solr, 'names:def*');
    dump(solr, 'moves:N*');
    end.
    $ pas search
    $ link search + psolr/libr
    $ run search
    search for : *:*
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    French defense - 1. e4, e6, 2. d4, d5,
    Sicilian defense - 1. e4, c5,
    Queens gambit - 1. d4, d5, 2. c4,
    Dutch defense - d4, f5,
    Reti opening - Nf3, d5, 2. c4,
    search for : names:defense
    French defense - 1. e4, e6, 2. d4, d5,
    Sicilian defense - 1. e4, c5,
    Dutch defense - d4, f5,
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    search for : moves:d4
    Dutch defense - d4, f5,
    Queens gambit - 1. d4, d5, 2. c4,
    French defense - 1. e4, e6, 2. d4, d5,
    search for : alltext:defense
    Dutch defense - d4, f5,
    Sicilian defense - 1. e4, c5,
    French defense - 1. e4, e6, 2. d4, d5,
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    search for : alltext:d4
    Dutch defense - d4, f5,
    Queens gambit - 1. d4, d5, 2. c4,
    French defense - 1. e4, e6, 2. d4, d5,
    search for : defense
    Dutch defense - d4, f5,
    Sicilian defense - 1. e4, c5,
    French defense - 1. e4, e6, 2. d4, d5,
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    search for : d4
    Dutch defense - d4, f5,
    Queens gambit - 1. d4, d5, 2. c4,
    French defense - 1. e4, e6, 2. d4, d5,
    search for : names:defense moves:d4
    Dutch defense - d4, f5,
    French defense - 1. e4, e6, 2. d4, d5,
    Queens gambit - 1. d4, d5, 2. c4,
    Sicilian defense - 1. e4, c5,
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    search for : names:defense AND moves:d4
    Dutch defense - d4, f5,
    French defense - 1. e4, e6, 2. d4, d5,
    search for : names:defense NOT moves:d4
    Sicilian defense - 1. e4, c5,
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    search for : defense d4
    Dutch defense - d4, f5,
    French defense - 1. e4, e6, 2. d4, d5,
    Queens gambit - 1. d4, d5, 2. c4,
    Sicilian defense - 1. e4, c5,
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    search for : defense AND d4
    Dutch defense - d4, f5,
    French defense - 1. e4, e6, 2. d4, d5,
    search for : defense NOT d4
    Sicilian defense - 1. e4, c5,
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    search for : names:def*
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    French defense - 1. e4, e6, 2. d4, d5,
    Sicilian defense - 1. e4, c5,
    Dutch defense - d4, f5,
    search for : moves:N*
    Spanish defense, Ruy Lopez - 1. e4, e5, 2. Nf3, Nc6, 3. Bb5,
    Reti opening - Nf3, d5, 2. c4,

    Very far from a complete API - only the most basic stuff.

    And there are restrictions including 32 KB limit on strings
    (VMS Pascal varying of char).

    But maybe still interesting.

    If anyone is interested then everything is available here:
    https://www.vajhoej.dk/arne/opensource/vms/vmspsolr-src-v0_1.zip

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to All on Mon Dec 9 21:04:40 2024
    On 12/6/2024 7:49 PM, Arne Vajhøj wrote:
    I have been looking a bit at Solr recently. For those that don't
    know Solr, then it is a text search engine - or more accurate it
    is a web frontend for the Lucene text search engine. Both
    Solr and Lucene are Apache projects (open source).

    Solr is basically exposing a web API, so anything that can do
    HTTP POST can use Solr. But clients encapsulating the HTTP
    stuff does exist for many languages. On VMS then both JVM languages
    and Python should be able to use a standard client.

    But there are also the traditional languages. Maybe it could
    be nice to be able to access Solr from one of those.  VMS Pascal
    is actually a very nice language, so I picked that. And I could
    reuse some stuff I had on the shelf.

    pSolr (Pascal)-|->phttp (Pascal)->vms_http (C)->vms_socket (C)->sockets
                   |->pJSON (Pascal)->cJSON (C, not written by me)

    To do a little stress test I tried stuffing the content of
    SYS$HELP:HELPLIB.HLB into Solr (two fields: path with the
    help path and helptext with the first 32 KB of the text).

    And then a little search program that output help commands
    that can be copy pasted.

    Examples:

    $ mcr []hhint fread
    help CRTL fread
    help CRTL fread Description
    help CRTL Version-Dependency_Tables All_OpenVMS_Versions
    help CRTL pipe Description
    $ mcr []hhint fread NOT fwrite
    help CRTL fread
    help CRTL fread Description
    $ mcr []hhint fread OR fwrite
    help CRTL fread
    help CRTL fwrite
    help CRTL Feature_Logical_Names DECC$STDIO_CTX_EOL
    help CRTL fwrite Description
    help CRTL fread Description
    help CRTL Feature_Logical_Names DECC$WRITE_SHORT_RECORDS
    help CRTL Version-Dependency_Tables All_OpenVMS_Versions
    help CRTL pipe Description

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)