Search code examples
intersystems-cacheobjectscript

Dynamic iFind Index without creating class Index of %iFind.Index.Basic


I am trying to make a general purpose text search feature with %iFind.Index.Basic.

According to the iFind Search Tool documentation, an iFind Index must be created in a Class as below:

Class Aviation.TestSQLSrch Extends %Persistent[...] 
{
...
Index NarrBasicIdx On (Narrative) As %iFind.Index.Basic(INDEXOPTION=0,
     LANGUAGE="en",LOWER=1);
...
}

But this only applies a field in one single class only.

If the iFind search feature needed to be used generally, then a lot of string fields need to be indexed and that is memory consuming and unpractical.

Is there anyway to do iFind indexing dynamically on demand without the need to alter the Class, and still able to be queried with ##Class(%ResultSet)?

In the documentation, it also mentioned Indexing a JSON Object, but without example given. Is this the place I should explored more on?


Solution

  • Using iFind, you first need to create an index and build it before executing any query (nothing dynamically here, as soon as it is index-based).

    If you want something more generic, maybe you should use some other Text Analytics options as NLP (Natural Language Processing)