Skip to content

Commit ee0347e

Browse files
committed
Подсказки в строке поиска без использования домена, используя
%iFind.FindEntities
1 parent ad64785 commit ee0347e

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

src/cls/iKnowDoc/Search/Domain.cls

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Class iKnowDoc.Search.Domain Extends %Persistent
44
{
55

66
/// Similar entity search method. Returns JSON-object containing 10 entities similar to input string.
7-
ClassMethod GetSimilar(SearchString) As %Status
7+
// Old version
8+
/*ClassMethod GetSimilar(SearchString) As %Status
89
{
910
try {
1011
if ($length(SearchString)>1) {
@@ -19,7 +20,7 @@ ClassMethod GetSimilar(SearchString) As %Status
1920
set Result(12) = $lb(999999," ",0,0)
2021
for i=1:1:10 {
2122
set оrd = $order(Result(i),1,Data)
22-
if $li(Result(i),4)>2 {
23+
if $li(Result(i),2)>2 {
2324
if ($FIND($li(Data,2),"--")'=0) {
2425
set string =" "
2526
} elseif ($FIND($li(Data,2),"|")'=0) {
@@ -46,6 +47,40 @@ ClassMethod GetSimilar(SearchString) As %Status
4647
write ResultJSON.%ToJSON()
4748
}
4849
quit $$$OK
50+
}*/
51+
52+
ClassMethod GetSimilar(SearchString) As %Status
53+
{
54+
try {
55+
if ($length(SearchString)>1) {
56+
// Forming a dynamic object
57+
set ResultJSON = { "entities": [] }
58+
// Getting data from Result array and pushing to the dynamic object
59+
//set myquery = "SELECT TOP 10 e.Word as Word, s.Spread FROM %iFind.FindWords('"_SearchString_"*') e JOIN User_DocBook.DocBook_contentInd_WordSpread s ON e.WordId= s.WordId ORDER BY Spread DESC"
60+
set myquery = "SELECT TOP 10 e.Entity as Word, s.Spread FROM %iFind.FindEntities('"_SearchString_"*') e JOIN User_DocBook.DocBook_contentInd_EntSpread s ON e.EntityId = s.EntityId where s.Spread > 2 ORDER BY Spread DESC"
61+
set tStatement = ##class(%SQL.Statement).%New()
62+
set qStatus = tStatement.%Prepare(.myquery)
63+
IF qStatus'=1 {WRITE "%Prepare failed:" DO $System.Status.DisplayError(qStatus) QUIT}
64+
set rset = tStatement.%Execute()
65+
//w 1
66+
//zw rset
67+
while rset.%Next() {
68+
set word=rset.Word
69+
//w rset.Word
70+
/*set string = ##class(iKnowDoc.Search.Parser).ParseHints(word)
71+
set tJSON = { "value":($ZCONVERT(string,"I","HTML")) }*/
72+
//set tJSON = { "value":($ZCONVERT(rset.Word,"I","HTML")) }
73+
set tJSON = { "value":(rset.Word) }
74+
do ResultJSON.entities.%Push(tJSON)
75+
}
76+
}
77+
// Converting dynamic object into JSON
78+
write ResultJSON.%ToJSON()
79+
} catch ex {
80+
set ResultJSON = { "entities": [] }
81+
write ResultJSON.%ToJSON()
82+
}
83+
quit $$$OK
4984
}
5085

5186
/// Getting iKnow domain Id method

0 commit comments

Comments
 (0)