Changes to wildcards in 8.5.2?
Friday, 22 July 2016 · 9 messages · last reply 26 Jul 2016
FB
France Baril22 Jul 2016 02:42 #
Hi,
This query works with 8.5.1 when the value of $wild-words is *.*, but not in 8.5.2. It works in 8.5.2 for real text values, so the issue seems to be with the *.* expression:
*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}))]Not seeing info about changes at
http://docs.basex.org/wiki/Full-Text
.
--
France Baril
Architecte documentaire / Documentation architect
france.baril at architextus.com
CG
Christian Grün22 Jul 2016 09:10 #
Hi France,
Could you provide us with an example that we can reproduce? The attached query returns the same result both versions. What is the leading * supposed to do in your query string?
The wildcard syntax didn’t change with 8.5.2, but we changed minor details regarding the way how queries are compiled.
Thanks
Christian
-----------------
let $search-subset :=
<x>
<title>one</title>
<text>two</text>
</x>
let $operator := 'and'
let $wild-words := '*.*'
return 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}))]FB
France Baril23 Jul 2016 00:21 #
This is the full function. The $doctype corresponds to the root element of the file. So if I have files that are concepts and tasks and I say search in doctype concept, no task will be returned.
<concept><title>concept blah</title><conbody>More blah</conbody></concept>
<task><title>task blah</title><taskbody>A bunch of
steps...</taskbody></task>*.* happens when the keyword section of the query is an empty string. 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>};
CG
Christian Grün23 Jul 2016 08:36 #
Quoted text · France Baril · 1 line
> 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.
Quoted text · France Baril · 1 line
> *.* 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.
Quoted text · France Baril · 17 lines
> > 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()],
' ')
Quoted text · France Baril · 5 lines
> else '' > let $last-keyword := tokenize(normalize-space($keywords), ' ')[last()] > let $wild-keywords := if (string-length($last-keyword) > 3) > then concat($first-words, ' ',
$last-keyword, '.*')Quoted text · France Baril · 2 lines
> else '' > let $all-wild-keywords := tokenize(normalize-space($wild-keywords),
' ')
Quoted text · France Baril · 9 lines
> > 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
Quoted text · France Baril · 2 lines
({$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}))]Quoted text · France Baril · 10 lines
> > 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)} {Quoted text · France Baril · 11 lines
> > > 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> > > };
CG
Confirmed [1]. Should be fixed soon.
Thanks
Christian
[1] https://github.com/BaseXdb/basex/issues/1323
Quoted text · France Baril · 122 lines
On Mon, Jul 25, 2016 at 11:49 PM, France Baril <france.baril at 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 at 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 at architextus.com
FB
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-resultsQuoted text · Christian Grün · 80 lines
On Fri, Jul 22, 2016 at 11:36 PM, Christian Grün <christian.gruen at 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 at architextus.com
CG
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/
Quoted text · Christian Grün · 132 lines
On Tue, Jul 26, 2016 at 1:05 AM, Christian Grün <christian.gruen at 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 at 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 at 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 at architextus.com
FB
France Baril26 Jul 2016 14:06 #
Thanks! I'll try it in the morning!
Quoted text · Christian Grün · 154 lines
On Tue, Jul 26, 2016 at 1:31 AM, Christian Grün <christian.gruen at 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 at 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 at 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 at 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 at architextus.com >
--
France Baril
Architecte documentaire / Documentation architect
france.baril at architextus.com
FB
France Baril26 Jul 2016 23:02 #
It works! Perfect!
Quoted text · France Baril · 171 lines
On Tue, Jul 26, 2016 at 3:06 AM, France Baril <france.baril at 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 at 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 at 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 at 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 at 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 at architextus.com >> > > > > -- > France Baril > Architecte documentaire / Documentation architect > france.baril at architextus.com >
--
France Baril
Architecte documentaire / Documentation architect
france.baril at architextus.com
Written for BaseX 8.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery