It works! Perfect!
On Tue, Jul 26, 2016 at 3:06 AM, France Baril france.baril@architextus.com wrote:
Thanks! I'll try it in the morning!
On Tue, Jul 26, 2016 at 1:31 AM, Christian Grün <christian.gruen@gmail.com
wrote:
Hi France,
This was a tricky one; the fulltext options got lost while inlining let expressions. Sorry that this little bug made it into the last release, it’s resolved in the latest snapshot [1].
Christian
[1] http://files.basex.org/releases/latest/
On Tue, Jul 26, 2016 at 1:05 AM, Christian Grün christian.gruen@gmail.com wrote:
Confirmed [1]. Should be fixed soon.
Thanks Christian
[1] https://github.com/BaseXdb/basex/issues/1323
On Mon, Jul 25, 2016 at 11:49 PM, France Baril france.baril@architextus.com wrote:
Try this:
Replace 'pub-en-us' by one of your dbs. If I replace $wild-words '*.*' by 't.*', I get results. If I use $wild-words as '*.*' or '.*' with 8.5.1, I get results. However '*.*' or '.*' in 8.5.2 returns nothing.
let $operator := 'and' let $wild-words := '.*' let $search-subset := db:open('pub-en-us')/*
let $search-result := if ($operator = 'and') then $search-subset[(descendant::title[1] contains text
({$wild-words}
all using wildcards weight {2})) or (. contains text ({$wild-words} all using wildcards weight {0.5}))] else $search-subset[(descendant::title[1] contains text
({$wild-words}
any using wildcards weight {2})) or (. contains text ({$wild-words} any using wildcards weight {0.5}))]
let $ordered-results := for $x score $s in $search-result order by $s descending, $x/title ascending return $x (: Adding no result in options because Safari 9.1.1 doesn't always respond to :empty no longer being empty after a $.get :) return $ordered-results
On Fri, Jul 22, 2016 at 11:36 PM, Christian Grün <
christian.gruen@gmail.com>
wrote:
This is the full function.
Do you have a query call that runs out of the box? Sorry for my persistence, but it usually takes us much more time reconstructing
use cases
than actually fixing potential bugs.
*.* happens when the keyword section of the query is an empty
string.
I'm still wondering about the leading *, because "*.*" and ".*" are equivalent patterns (in the first string, the leading * will simply be ignored).
We assume that the user wants all results for the specified doctype.
If no
doctype (empty string) is specified, we assume they want the entire
library.
In 8.5.2, I get 0 item found when I search for keywords = ''
declare
function search:search-all($doctype as xs:string, $keywords as xs:string, $operator as xs:string, $lang as xs:string) as node(){ let $keywords := if (normalize-space($keywords)='') then '*' else $keywords let $words := tokenize(normalize-space($keywords), ' ') let $wild-words := for $word in $words return concat($word, '.*') let $first-words := if (count($words) > 1) then string-join($words[position()!=last()], ' ') else '' let $last-keyword := tokenize(normalize-space($keywords), ' ')[last()] let $wild-keywords := if (string-length($last-keyword) > 3) then concat($first-words, ' ', $last-keyword, '.*') else '' let $all-wild-keywords :=
tokenize(normalize-space($wild-keywords),
' ')
let $search-subset := if ($doctype = '') then db:open($lang)/* else db:open($lang)/*[name()=$doctype]
let $search-result := if ($operator = 'and') then $search-subset[(descendant::title[1] contains text ({$wild-words} all using wildcards weight {2})) or (. contains text ({$wild-words} all using wildcards weight {0.5}))] else $search-subset[(descendant::title[1] contains text ({$wild-words} any using wildcards weight {2})) or (. contains text ({$wild-words} any using wildcards weight {0.5}))]
let $ordered-results := for $x score $s in $search-result order by $s descending, $x/title
ascending
return $x
(: Adding no result in options because Safari 9.1.1 doesn't
always
respond to :empty no longer being empty after a $.get :) return <div> <div style="width:100%;"> <span style="display:inline-block; font-style:italic; text-align:right; width:100%;">{count($ordered-results)} {
if (count($ordered-results) < 2) then resources:get-app-string('item-found', $lang) else resources:get-app-string('items-found',
$lang)
}</span> </div> {search:format-result-docs-as-table($ordered-results,
$lang)} </div>
};
-- France Baril Architecte documentaire / Documentation architect france.baril@architextus.com
-- France Baril Architecte documentaire / Documentation architect france.baril@architextus.com