我必须将地理空间搜索功能添加到使用 search:search API 并具有全文搜索和分面搜索的现有应用程序中。我已经阅读了有关扩展搜索 API 的信息,但我现在没有时间。所以,我想我会调整我的代码,以便只做两个结果集的交集(一个由 search:search API 返回,另一个由cts:search
允许cts:polygon
搜索的返回)。不幸的是,交叉点严重降低了执行时间。有没有更好的方法来优化或加速下面的表达式?
$results_fts//search:result[./search:metadata/Vhe eq $geo_results//root/Vhe]
这是我的代码:
declare variable $geo_results :=
let $qr := cts:search(doc(), cts:and-query(($q-geospatial,
cts:word-query("*", ("case-insensitive","whitespace-insensitive","wildcarded","diacritic-insensitive")) )) ) (:Search all * within the polygon:)
return $qr;
declare variable $results_fts :=
let $qrs := search:search($q-text, $options, xs:unsignedLong(xdmp:get-request-field("start","1")), 12000) (:max page length to get all records:)
return $qrs;
declare variable $results :=
let $qrt := if (xdmp:get-request-field("map-code")) then
(:intersect geospatial search with the full text search:)
<search:response>
{ $results_fts//search:result[./search:metadata/Vhe eq $geo_results//root/Vhe] }
{ $results_fts//search:facet }
{ $results_fts//search:qtext }
{ $results_fts//search:metrics }
</search:response>
else $results_fts
return $qrt;