[basex-talk] Can XQuery return unique values present across multiple databases?

2021-08-12 Thread Tamara Marnell
Short question: Is it possible to write an XQuery FLWOR statement that can
return a set of unique values present across multiple databases?

Long question: Our new website in development displays EAD finding aids
stored across 45 databases in BaseX. I've built "facet" databases that
index terms in the EADs from controlled vocabularies like subjects, places,
personal names, etc. The indexes follow this structure, where each EAD node
contains a unique identifier:


  
12345
67890
  
  
abcde
  
  {etc.}


In the search interface, users can select multiple facets to apply to one
search. For example, they could browse database 12 for EADs with the
subject "Literature" *and* the place "Oregon," etc.

I currently use the REST server to run an XQuery file that loops through
each selected facet and prints *all* EAD IDs for each submitted term and
database. Then after results are returned, I use PHP to count occurences of
each EAD and print them only if the total count matches the count of facets
used.

declare variable $d as xs:string external;
declare variable $f as xs:string external;
let $db_ids := tokenize($d, '\|')
return {
for $facet in tokenize($f, '\|')
  let $split := tokenize($facet, ':')
  let $facet_type := $split[1]
  let $facet_term := $split[2]
  let $facet_db := 'facet-' || $facet_type
  return {
for $ead in db:open($facet_db)/terms/term[@text=$facet_term and
@db=$db_ids]/ead
  return $ead
  }
}

So in the hypothetical example above, I'd pass "12" as d (or multiple
selected databases separated by bars) and
"subject:Literature|geogname:Oregon" as f, and I'd get back a document like:


  
12345
67890
  
  
12345
  


The count of "12345" will equal the count of the user's selected facets, so
that result will be printed, but 67890 will not.

Is there a more efficient way to do this? I'd prefer the XQuery to return
only the EADs that meet all criteria, so only 12345 would be returned
because it's in facet-subject under Literature *and* in facet-geogname
under "Oregon," and then I don't have to do any post-processing.

-Tamara

-- 

Tamara Marnell
IT Manager
Orbis Cascade Alliance (orbiscascade.org )
Pronouns: she/her/hers


Re: [basex-talk] Pretty-print the -V optimized query? See what indexes are used?

2021-08-12 Thread Christian Grün
Hi Jonathan,

> Is there a way to pretty-print the optimized query from the -V option?

Currently no. Personally, I’m not aware of any XQuery code formatter
that works really well. Maybe anyone else on the list does?

> What is the best way to see which indexes are being used?

The usual way is to parse the compilation output for "apply ... index"
entries. Our documentation might give you some more hints [1].

Cheers,
Christian

[1] https://docs.basex.org/wiki/Indexes


Re: [basex-talk] org.basex.core.BaseXException with no error message

2021-08-12 Thread Christian Grün
Hi Matt,

It’s difficult to give a general answer. Do you think you can share a
reproducible test case with us?

Thanks in advance
Christian



On Thu, Aug 12, 2021 at 3:01 PM Matthew Dziuban  wrote:
>
> Hi all,
>
> I'm using the java ClientSession class defined in the basex-api module and 
> I'm seeing intermittent org.basex.core.BaseXException errors with an empty 
> error message when executing long-running read queries or CREATE DB commands. 
> The stack trace of the most recent error points to ClientSession.receive 
> (https://github.com/BaseXdb/basex/blob/9.5.2/basex-core/src/main/java/org/basex/api/client/ClientSession.java#L190)
>
> org.basex.core.BaseXException:
> org.basex.api.client.ClientSession.receive(ClientSession.java:190)
> org.basex.api.client.ClientSession.send(ClientSession.java:178)
> org.basex.api.client.ClientSession.send(ClientSession.java:215)
> org.basex.api.client.ClientSession.create(ClientSession.java:128)
> ...
>
> Unfortunately since the message is empty it's difficult to debug what's going 
> wrong. I've checked the log files in basex/data/.logs but haven't found any 
> information about the failure. Is there another place I can look? Or do you 
> have any other recommendations for debugging the errors?
>
> Thanks in advance,
> Matt


[basex-talk] org.basex.core.BaseXException with no error message

2021-08-12 Thread Matthew Dziuban
Hi all,

I'm using the java ClientSession class defined in the basex-api module and
I'm seeing intermittent org.basex.core.BaseXException errors with an empty
error message when executing long-running read queries or CREATE DB
commands. The stack trace of the most recent error points to
ClientSession.receive (
https://github.com/BaseXdb/basex/blob/9.5.2/basex-core/src/main/java/org/basex/api/client/ClientSession.java#L190
)

org.basex.core.BaseXException:
org.basex.api.client.ClientSession.receive(ClientSession.java:190)
org.basex.api.client.ClientSession.send(ClientSession.java:178)
org.basex.api.client.ClientSession.send(ClientSession.java:215)
org.basex.api.client.ClientSession.create(ClientSession.java:128)
...

Unfortunately since the message is empty it's difficult to debug what's
going wrong. I've checked the log files in basex/data/.logs but haven't
found any information about the failure. Is there another place I can look?
Or do you have any other recommendations for debugging the errors?

Thanks in advance,
Matt


Re: [basex-talk] XProc?

2021-08-12 Thread Imsieke, Gerrit, le-tex

We couple it more loosely using RESTXQ endpoints and HTTP requests.

On 12.08.2021 13:58, Jonathan Robie wrote:
What hooks does BaseX provide for XProc?  Where can I find examples of 
BaseX use in an XProc pipeline?


Jonathan


[basex-talk] Pretty-print the -V optimized query? See what indexes are used?

2021-08-12 Thread Jonathan Robie
Is there a way to pretty-print the optimized query from the -V option?

What is the best way to see which indexes are being used?

Jonathan


Re: [basex-talk] XProc?

2021-08-12 Thread Martin Honnen



Am 12.08.2021 um 13:58 schrieb Jonathan Robie:

What hooks does BaseX provide for XProc?  Where can I find examples of
BaseX use in an XProc pipeline?



Morgana XProc for XProc 1 has support for using BaseX for the p:xquery
step:
https://www.xml-project.com/documentation/morgana-userguide/morganaxproc_enhance/#xquery



[basex-talk] XProc?

2021-08-12 Thread Jonathan Robie
What hooks does BaseX provide for XProc?  Where can I find examples of
BaseX use in an XProc pipeline?

Jonathan