Generally I'd do this as follows:
Class DC.Demo.DefinesIndices Extends %Persistent [ Abstract, NoExtent ]
{
Index TXSBI On TextSearch(KEYS);
Index TXSSI On TextSimilarity(KEYS) [ Data = TextSimilarity(ELEMENTS) ];
Property TextSearch As %Text(LANGUAGECLASS = "%Text.English", MAXLEN = 1000, XMLPROJECTION = "NONE");
Property TextSimilarity As %Text(LANGUAGECLASS = "%Text.English", MAXLEN = 1000, SIMILARITYINDEX = "TXSSI", XMLPROJECTION = "NONE");
}
Class DC.Demo.InheritsIndices Extends DC.Demo.DefinesIndices
{
Storage Default
{
<Data name="InheritsIndicesDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>TextSearch</Value>
</Value>
<Value name="3">
<Value>TextSimilarity</Value>
</Value>
</Data>
<DataLocation>^DC.Demo.InheritsIndicesD</DataLocation>
<DefaultData>InheritsIndicesDefaultData</DefaultData>
<IdLocation>^DC.Demo.InheritsIndicesD</IdLocation>
<IndexLocation>^DC.Demo.InheritsIndicesI</IndexLocation>
<StreamLocation>^DC.Demo.InheritsIndicesS</StreamLocation>
<Type>%Storage.Persistent</Type>
}
}Key points:
- Indices are only inherited from the primary superclass (see https://docs.intersystems.com/iris20212/csp/docbook/DocBook.UI.Page.cls…) - the docs aren't super clear on this.
- Your primary superclass needs to be persistent
- [Abstract, NoExtent] lets you define a class that extends %Persistent but doesn't have storage - so subclasses have their own storage (which is presumably what you want)
- Log in to post comments