%iFind.Highlight
Hi
I've been working with SQL using an iFind index to search text. Using the %iFind.Highlight function in my SELECT statement I can get text back that highlights the found words using <b> and </b>
I am aware that using ##class(%iFind.Utils).Highlight, I can pass a parameter to override the <b> tag and use instead a <span> tag with style to change the background color of the found words.
Is there a way to override the <b> tag from a SQL statement?
Thanks
Since ##class(%iFind.Utils).Highlight and %iFind.Highlight are the same method, you can pass fourth pTags argument to it:
SELECT %iFind.Highlight(Narrative,'"visibility [1-4] mile*" AND "temp* ? degrees"', , "<span>")
Eduard,
I had seen that in the docs and have tried various flavors of it. I am using embedded SQL in a classmethod here to do my search. Here's the method
When I try to use this, I get:
Any thoughts on why this is erroring?
Try double quotes inside:
SELECT %iFind.Highlight(Text , :pSearchString , ,'<span style="background-color:yellow;">') into :results FROM SSA_OCR.TempSearchable
I checked on my dataset and this query works for me:
SELECT *, %iFind.Highlight(Text,'hello', , '<span style="background-color:yellow;">') FROM Test.Data WHERE %ID %FIND search_index(TextIndex,'hello')
Interesting. I did get this to work but don't believe it's calling the %iFind.Utils:Highlight method. The reason I say this is that the method has extra parameters that don't correspond to the SQL %Fimd.Highlight SQL function.
What do you mean? Highlight method signature:
ClassMethod Highlight(pText As %String, pSearchString As %String, pSearchOption As %String = {$$$IFSEARCHNORMAL}, pTags As %String = {$$$IFDEFAULTHLTAGS}, pLimit As %Integer = 0, pLanguage As %String = "en", Output pSC As %Status) As %String [ SqlName = Highlight, SqlProc ]
Shows that it is available in SQL context (bolded). All classmethod arguments (except sc) can be passed from SQL.
I must not have had enough coffee today because it looks right to me.
:)