hi,I want to create a index using tamino API for java,how can I do that?
I using a tsd file and TXMLObject class to define a schema,but how can i create index in a schema?
Hello izyw,
I am not sure whether you can declare indexes for a Schema using Tamino API for java. Because the normal process is, when we define Schema, we declare indexes on the nodes. And Schema Editor Helps you in declaring these indexes. Once the Schema is defined in the Tamino, whenever the Instances are added, Tamino use this Index info from Schema to define the Indexes in Index table.
Regards,
Prashant Jedhe
Hello izyw,
In theory it should be possible to use the Tamino API for Java to add indexes since the schema document is just an XML document. There are no methods in the TaminoAPI4J for manipulation of the schema so this is something that you could do yourself using DOM or JDOM. The Tamino documentation explains extensions to the xml schema for such things as indices. IMO this is something that could be accomplished with some coding effort.
Hope this helps.
Stuart Fyffe-Collins
Software AG (UK) Ltd.
Hello izyw,
Stuart’s suggestion is precisely what I would propose. As Stuart describes, you can load the schema definition into a DOM structure in memory (using either the TDOMObjectModel or the TJDOMObjectModel) and then add the appropriate elements to define indexes.
Here is a small example to show what needs to be done at the schema level.
If, for example, there is an attribute “a” in the schema to which a standard index should be added… The original definition of “a” might look something like this in the schema:
<xs:attribute name="a" type="xs:string"></xs:attribute></pre><BR>To define a standard index on this attribute, it is necessary to add some further elements:<BR><pre class="ip-ubbcode-code-pre"> <xs:attribute name="a" type="xs:string">
<xs:annotation>
<xs:appinfo>
<tsd:attributeInfo>
<tsd:physical>
<tsd:native>
<tsd:index>
<tsd:standard/>
</tsd:index>
</tsd:native>
</tsd:physical>
</tsd:attributeInfo>
</xs:appinfo>
</xs:annotation>
</xs:attribute>
Although this may look a little daunting, keep in mind that you do not need to add the start & end tags in the DOM, just add child elements to the correct elements… Although you could also do a String based approach to modifying the schema, where you just insert the boilerplate text between the xs:attribute tags.
In either case the code to add this information will be reusable, as the tags from xs:annotation down will be the same (they will just be children of different elements).
The definition of a text index only differs in that the tag will be “tsd:text” rather than “tsd:standard”.
I hope that helps,
Trevor.
to Prashant Jedhe:
At first,I didn’t create index in schema file when I use schema editor,but as the data comes more and more,the query is so slowly,so I want to create some index ,but the datas have been stored in the database,so I can’t create another schema that has index,then load the data,if do so,the cost is so expensive.
to Trevor Ford and Stuart Fyffe-Collins:
as say to Prashant Jedhe,I want to add/delete some index after the schema has been created and the data has been loaded into the collection.so what should I do? just as relation database,i can create any index using “create index …” .
Thanks in advance.
Best regards,
GavinZheng
The way indices are added is by modification of the schema. The schema document contains the index definition (see Trevor’s example above). When the schema is (re)defined to Tamino, it will automatically perform the index creation. The normal flow of operation is:
- use Tamino schema editor
- load in the schema from the database
- specify the index or indices
- define the schema to Tamino (result in index creation).
If you want to this programatically then the methodology outlined by myself and Trevor should work. IMO if this is a one-off task then simply use the schema editor to add the index.
Hope this helps.
Stuart Fyffe-Collins
Software AG (UK) Ltd.