Skip to content

Commit f7b97be

Browse files
committed
Исправлен SQL запрос пагинации
1 parent b671deb commit f7b97be

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/cls/iKnowDoc/Search/SearchPages.cls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ ClassMethod FormQuery(obj) As %Status
154154
// Data table query
155155
// TODO frequency sorting in iFind doesn't work fast enough due to DB containg text paragraphs, not text of a whole page.
156156
if rank = 1 {
157-
set resultQuery = "select * from (select TOP "_recordCount_" * from (select TOP "_offset_" * from(select count(*) as cnt,* from(select *, sum(RankOne) as Rank from (select component->blockid AS docKey, component->title AS title,book->blockid AS bookKey, book->title AS bookTitle, DocBook.block_contentIndRank(%ID, ?, ?) RankOne FROM DocBook.block WHERE %ID %FIND search_index(contentInd,?,?)) group by title)) order by RANK DESC,title DESC) order by RANK ASC,title ASC) order by RANK DESC,title DESC"
157+
set resultQuery = "select * from (select TOP ? * from (select TOP ? * from(select count(*) as cnt,* from(select *, sum(RankOne) as Rank from (select component->blockid AS docKey, component->title AS title,book->blockid AS bookKey, book->title AS bookTitle, DocBook.block_contentIndRank(%ID, ?, ?) RankOne FROM DocBook.block WHERE %ID %FIND search_index(contentInd,?,?)) group by title)) order by RANK DESC,title DESC) order by RANK ASC,title ASC) order by RANK DESC,title DESC"
158158
} else {
159-
set resultQuery = "select * from (select TOP "_recordCount_" * from (select TOP "_offset_" * from(select count(*) as cnt,* from(select *, count(*) as Rank from (select component->blockid AS docKey, component->title AS title,book->blockid AS bookKey, book->title AS bookTitle FROM DocBook.block WHERE %ID %FIND search_index(contentInd,?,?)) group by title))order by RANK DESC,title DESC) order by RANK ASC,title ASC) order by RANK DESC,title DESC"
159+
set resultQuery = "select * from (select TOP ? * from (select TOP ? * from(select count(*) as cnt,* from(select *, count(*) as Rank from (select component->blockid AS docKey, component->title AS title,book->blockid AS bookKey, book->title AS bookTitle FROM DocBook.block WHERE %ID %FIND search_index(contentInd,?,?)) group by title))order by RANK DESC,title DESC) order by RANK ASC,title ASC) order by RANK DESC,title DESC"
160160
}
161161
//set resultQuery = "select * from (select TOP "_recordCount_" * from (select TOP "_offset_" * from(select count(*) as cnt,* from(select *, sum(RankOne) as Rank from (select component->blockid AS docKey, component->title AS title,book->blockid AS bookKey, book->title AS bookTitle, DocBook.block_contentIndRank(%ID, ?, '0') RankOne FROM DocBook.block WHERE %ID %FIND search_index(contentInd,?,?))order by RANK DESC,title DESC) order by RANK ASC,title ASC) order by RANK DESC,title DESC"
162162
//set resultQuery = "select * from (select TOP "_recordCount_" * from (select TOP "_offset_" * from(select count(*) as cnt,* from(select *, count(*) as Rank from (select component->blockid AS docKey, component->title AS title,book->blockid AS bookKey, book->title AS bookTitle FROM DocBook.block WHERE %ID %FIND search_index(contentInd,?,?)) group by title))order by RANK DESC,title DESC) order by RANK ASC,title ASC) order by RANK DESC,title DESC"
@@ -165,9 +165,9 @@ ClassMethod FormQuery(obj) As %Status
165165
set Status = Statement.%Prepare(resultQuery)
166166
if Status'=1 {write "%Prepare failed 1:" do $System.Status.DisplayError(Status) quit}
167167
if rank = 1{
168-
set result = Statement.%Execute(text,fuzzy,text,fuzzy)
168+
set result = Statement.%Execute(recordCount,offset,text,fuzzy,text,fuzzy)
169169
} else {
170-
set result = Statement.%Execute(text,fuzzy)
170+
set result = Statement.%Execute(recordCount,offset,text,fuzzy)
171171
}
172172
// Forming a dynamic object
173173
set ResultJSON = { "sources": [], "totalCount":[]}

0 commit comments

Comments
 (0)