iFind and HTML text

iFind, iKnow

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?

  • + 1
  • 0
  • 245
  • 3
  • 1

Respuestas

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

Thank you, Benjamin.

I thought TRANSFORMATIONSPEC parameter could have been used somehow, but I'll try your suggested approach.

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.

Make plaintext property triggered computed on insert/update rather than always computed.

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