Question
· Jun 26, 2017

iFind and HTML text

I have a class with text property, which contains html text (usually pieces, so it may be invalid), here's a sample value:

<div moreinfo="none">Word1 Word2</div><br>
<a href = "123" >Word3</a>

When I add iFind index on text, there are at least two problems:

  • Words like moreinfo="none">Word1, so exact match with Word1 returns nothing
  • Irrelevant results for href search

How can I pass plaintext into iFnd index?

Discussion (4)0
Log in or sign up to continue

Hi Eduard,

you can define iFind indices for calculated fields, so if you point your field calculation to a function that strips out the HTML, you should be fine. The HTML converter in iKnow was built for a slightly different purpose, but can be used here:

Property HtmlText As %String(MAXLEN="");

Property PlainText As %String(MAXLEN="") [ Calculated, ReadOnly, SqlComputed, SqlComputeCode = { set {PlainText} = ##class(%iKnow.Source.Converter.Html).StripTags({HtmlText}) } ];

Regards,
benjamin

Hi Benjamin.

I defined this property, 

Property HtmlText As %String(MAXLEN="");

Property PlainText As %String(MAXLEN="") [ Calculated, ReadOnly, SqlComputed, SqlComputeCode = { set {PlainText} = ##class(%iKnow.Source.Converter.Html).StripTags({HtmlText}) } ];

I need use iFind index on Property PlainText
But, I can not define iFind index on PlainText. I wrote like this
Index plainTextInd On (PlainText) As %iFind.Index.Analytic(INDEXOPTION = 2, LANGUAGE = "en", LOWER = 1, RANKERCLASS = "%iFind.Rank.Analytic"); , build index and than I had empty index.

I read in documentation, https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY..., that "if you intend to index this field, use deterministic code, rather than nondeterministic code. Caché cannot maintain an index on the results of nondeterministic code because it is not possible to reliably remove stale index key values. (Deterministic code returns the same value every time when passed the same arguments. So for example, code that returns $h is nondeterministic, because $h is modified outside of the control of the function.)", so I think that we can not use index on calculated property.

Can We use iFind index on Calculated Property?

Thanks,Konstntin Eremin.