Hi, 

I'm trying to build something that is similar to custom indices but that actually returns resolved nodes (nodes created by manipulating and merging nodes from the original DB).

1- I created a script that creates new index DBs. UPDINDEX and AUTOOPTIMIZED are set on both the 'index' DB and the DB from which the new DBs were created
2- I can create a query on any of the new 'index' DBs to extract the nodes I want.
3- After I change the content in the source DB, the response shows that the nodes in the 'index' DBs are not updated. I get the old result.

I feel that I am missing a link between the source and the index DBs to make the update mechanism work. Since I do not want to get the original node, but one that I create, I did not use db:node-id or db:open-id shown in the documentation example. Is that where the link is created?

CODE THAT CREATES THE INDEX DBs

let $langs :=
   for $lang in ('en-us', 'es-es') (:db:list()[string-length(.) = 5][substring(., 3, 1) = '-']:)
   return $lang
return
   for $lang in $langs
   let $index := <index>{
      for $string-group in db:open('global-content')//*[name()='string-group']
      let $prompt-this-lang := $string-group/child::*[@xml:lang=$lang][normalize-space(.)!='']
      let $prompt-base :=
         if (exists($prompt-this-lang))
         then $prompt-this-lang
         else $string-group/child::*[@xml:lang='en-us']
       let $prompts :=
           for $prompt-match in db:open('global-content')/*[name()='prompt-refs']/*[name()='prompt'][@package=$string-group/data(@package)][@pkg-version=$string-group/data(@pkg-version)][@key=$string-group/data(@key)]
          return
             copy $copy := $prompt-base
             modify (
                for $attr in $prompt-match/@*[name()!='package'
                   and name()!='pkg-version' and name()!='key']
                return insert node $attr into $copy
             )
             return $copy
     
       return
           $prompts
           
       
   }</index>
     
   return db:create('index-prompt-' || $lang, $index, 'prompts-' || $lang || '.xml', map { 'updindex': true(), 'autooptimize': true() })

CODE THAT QUERIES THE 'INDEX' DBS

(# db:enforceindex #) {
   for $prompt in db:attribute('index-prompt-en-us', 'setup_as_new', 'name')/..
   return $prompt => prof:time()
}

--
France Baril
Architecte documentaire / Documentation architect
france.baril@architextus.com