Forum OpenACS Q&A: Glossary and datasource for OpenFTS. Any working model?

Hi OpenFTS experts 😉
We are absolutely unable to make work the OpenFTS with the Glossary.
We have also looked at the cvs for oacsc 4.6 and the datasource there.
Neither we can't make work the search code on the cvs.
We are using OACS 4.5 and we have try to implement a datasource for glossary.
I include the code for our actual implementation.

In the search of glossaries we use the following query in the datasource procedure:
      select r.revision_id as object_id,
        r.name as title,
        r.content as content,
        r.mime_type as mime,
        r.name as keywords,
        'text' as storage_type
from cr_revisions r
        where revision_id = :object_id

It appears that the 'content' field of the 'cr_revisions' table doesn't fill up when we create a glossary.
Their description it's in the field 'description' of the 'cr_revisions' table.

The code we are using is:

  select r.item_id as object_id,
        r.title as title,
              r.description as content,
        r.mime_type as mime,
        '' as keywords,
        i.storage_type
from cr_revisions r, cr_items i
where i.item_id = :object_id
        and i.item_id = r.item_id
and i.live_revision = r.revision_id
and i.content_type = 'glossary'

This goes ok if we run it in plsql.

If we search a word that  _exist_ we have the following error at the search webpage.
If the word _doesn't exist_ there is no error.

HTTP/1.0 200 OK Content-Type: text/html; charset=iso-8859-1
MIME-Version: 1.0 Date: Mon, 10 Feb 2003 19:05:42 GMT Server:
AOLserver/3.3.1+ad13 Content-Length: 2621 Connection: close
Request Error

can't read "datasource(content)": no such element in array
    while executing
"search_content_get txt $datasource(content) $datasource(mime)
$datasource(storage_type)"
    ("for" body line 6)
    invoked from within
"for { set __i 0 } { $__i < [expr $high - $low +1] } { incr __i } {

set object_id [lindex $result(ids) $__i]
set object_type [db_exec_plsql get_obje..."
    ("uplevel" body line 89)
    invoked from within
"uplevel {
      ad_page_contract {
    @author Neophytos Demetriou <mailto:k2pts@cytanet.com.cy>
    @creation-date September 01, 2001
    @cvs-id $Id: sear..."
    (procedure "code::tcl::/web/openacs-dev/packages/search/www/search"
line 2)
    invoked from within
"code::tcl::$__adp_stub"
    invoked from within
"if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is
up-to-date
      adp_init tcl $__adp_stub
..."
    ("uplevel" body line 3)
    invoked from within
"uplevel {

    if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is
up-to-date
      adp_init t..."
    (procedure "adp_prepare" line 3)
    invoked from within
"adp_prepare "
    (procedure "template::adp_parse" line 30)
    invoked from within
"template::adp_parse [file root [ad_conn file]] {}"
    (procedure "adp_parse_ad_conn_file" line 7)
    invoked from within
"$handler"
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
$handler
      } ad_script_abort val {
# do nothing
      }"
    invoked from within
"rp_serve_concrete_file [ad_conn file]"
    (procedure "rp_serve_abstract_file" line 60)
    invoked from within
"rp_serve_abstract_file "$root/$path""
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
rp_serve_abstract_file "$root/$path"
set tcl_url2file([ad_conn url]) [ad_conn file]
set tcl_url2path_info([ad_conn url]) [ad_conn path_inf..."

We also don't understand why appears to exists two different 'object_id'.
One to index the results, and another when we want to search.

Last question. Why don't exists any mean to delete glossary's item??.

I hope you could give us some advice.

Thanks.
-------

The actual implementation we are triying to use (without success):
------
revista-dgtal-sc-procs.tcl
-----
# static-pages/tcl/glossary-sc-procs.tcl
# implements OpenFTS Search service contracts
# Don Baccus mailto:dhoghaza@pacifier.com
# poached from static-pages and notes

ad_proc cr_glossary__datasource {
    object_id
} {
    Provides data source for search interface.  Used to access content items
    after search.
} {
    db_0or1row datasource "
    select r.item_id as object_id,
          r.title as title,
              r.description as content,
          r.mime_type as mime,
          '' as keywords,
          i.storage_type
    from cr_revisions r, cr_items i
    where i.item_id = :object_id
        and i.item_id = r.item_id
    and i.live_revision = r.revision_id
    and i.content_type = 'glossary'
    " -column_array datasource

    return [array get datasource]
}

ad_proc cr_glossary__url {
    object_id
} {
    Provides a url for linking to content items which show up in a search
    result set.
} {

    set package_id [apm_package_id_from_key revista-dgtal]
    db_1row get_url_stub "
        select site_node__url(node_id) as root_url
          from site_nodes n
        where n.object_id = :package_id
    "

#    return "[string trimright $root_url /]glossary?item_id=$object_id"
    db_1row get_item_id "select item_id from cr_revisions where revision_id = :object_id"
    append url_return "$root_url" "glossary?item_id=$item_id"

    return $url_return
}

ad_proc cr_term__datasource {
    object_id
} {
    Provides data source for search interface.  Used to access content items
    after search.
} {
    db_0or1row datasource "
    select r.item_id as object_id,
          r.title as title,
              r.conten as content,
          r.mime_type as mime,
          '' as keywords,
          i.storage_type
    from cr_revisions r, cr_items i
    where i.item_id = :object_id
        and i.item_id = r.item_id
    and i.live_revision = r.revision_id
    and i.content_type = 'glossary_term'
    " -column_array datasource

    return [array get datasource]
}

ad_proc cr_term__url {
    object_id
} {
    Provides a url for linking to content items which show up in a search
    result set.
} {

    set package_id [apm_package_id_from_key revista-dgtal]
    db_1row get_url_stub "
        select site_node__url(node_id) as root_url
          from site_nodes n
        where n.object_id = :package_id
    "

#    return "[string trimright $root_url /]glossary?item_id=$object_id"
    db_1row get_item_id "select item_id from cr_revisions where revision_id = :object_id"
    append url_return "$root_url" "term?item_id=$item_id"

    return $url_return
}

------
revista-dgtal-sc-create.sql
-----

-- Implement OpenFTS Search service contracts
-- Dave Bauer mailto:dave@thedesignexperience.org
-- 2001-10-27

----------------------
------------- Glossary's Search
---------------------
select acs_sc_impl__new(
    'FtsContentProvider',        -- impl_contract_name
    'glossary',            -- impl_name
    'revista-dgtal'            -- impl_owner.name
);

select acs_sc_impl_alias__new(
    'FtsContentProvider',        -- impl_contract_name
    'glossary',            -- impl_name
    'datasource',            -- impl_operation_name
    'cr_glossary__datasource',        -- impl_alias
    'TCL'                -- impl_pl
);

select acs_sc_impl_alias__new(
    'FtsContentProvider',        -- impl_contract_name
    'glossary',            -- impl_name
    'url',                -- impl_operation_name
    'cr_glossary__url',        -- impl_alias
    'TCL'                -- impl_pl
);

----------------------
------------- Term's Search
---------------------
select acs_sc_impl__new(
    'FtsContentProvider',        -- impl_contract_name
    'glossary_term',        -- impl_name
    'revista-dgtal'            -- impl_owner.name
);

select acs_sc_impl_alias__new(
    'FtsContentProvider',        -- impl_contract_name
    'glossary_term',        -- impl_name
    'datasource',            -- impl_operation_name
    'cr_term__datasource',        -- impl_alias
    'TCL'                -- impl_pl
);

select acs_sc_impl_alias__new(
    'FtsContentProvider',        -- impl_contract_name
    'glossary_term',        -- impl_name
    'url',                -- impl_operation_name
    'cr_term__url',            -- impl_alias
    'TCL'                -- impl_pl
);