Migration queryIndexEnabled from gridgain to apache ignite

classic Classic list List threaded Threaded
5 messages Options
pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Migration queryIndexEnabled from gridgain to apache ignite

This post was updated on .
asked by nicolas héron

I am migration my application from gridgain 6.2.0 to apache ignite 1.0.0. I am using sql queries. How can I configure that in apache ignite. The queryIndexEnabled does not see to exist anymore Thanks

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss

pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Re: Migration queryIndexEnabled from gridgain to apache ignite

commented by alexey kuznetsov

Nicolas, please read http://apacheignite.readme.io/v1.0/docs/cache-queries Also, please mind that queries were significantly reworked in Ignite comparing with Gridgain 6.x. And I would recommend you to use latest version of Ignite 1.1.0 that was send for release vote yesterday (it contains several important fixes for queries) .

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss
pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Re: Migration queryIndexEnabled from gridgain to apache ignite

This post was updated on .
commented by nicolas héron

Hello, I read that. As 1.1.0 is not available I take version 1.1.0-SNAPSHOT when I do the request .
Ignite grid = Ignition.start("example-cache.xml"); IgniteCache<String, ContextUtilisateurIndex> cache =grid.cache("local_tx_indexusercontext"); IgniteCache<String, ContextUtilisateurIndex> contextUtilisateurIndexIgniteCache = getCache(); SqlQuery sql = new SqlQuery(ContextUtilisateurIndex.class, "= ?"); QueryCursor<Cache.Entry<String, ContextUtilisateurIndex>> cursor = cache.query(sql.setArgs(userId));

I get the following error Caused by: javax.cache.CacheException: Indexing is disabled for cache: local_tx_indexusercontext

here is my example-cache.xml file
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">

    <property name="cacheConfiguration" >
        <list>

            <bean parent="cache-template">
                <property name="name" value="local_tx_indexusercontext"/>
                <property name="cacheMode" value="LOCAL"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
            </bean>

        </list>
    </property>
   

</bean>



<bean id="cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
   
    <property name="startSize" value="3000000"/>
    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
</bean>
</beans>

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss
pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Re: Migration queryIndexEnabled from gridgain to apache ignite

This post was updated on .
commented by andrey gura

Nicolas,

The first, you need to enable indexing in your cache configuration. In order to do it just add the following lines to cacheConfiguration bean (NOTE: Use fully-qualified class names):

<property name="indexedTypes">
    <list>
        <value>java.lang.String</value>
        <value>your.package.ContextUtilisateurIndex</value>
    </list>
</property>


The second problem is that your query isn't correct. Just rewrite query as _key = ?.

It should work.

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss
pgarg pgarg
Reply | Threaded
Open this post in threaded view
|

Re: Migration queryIndexEnabled from gridgain to apache ignite

commented by valentin kulichenko

Nicolas,

Now there two options to configure indexing:

1. Using @QuerySqlField annotation. In this case you will have to provide types that need to be indexed via CacheConfiguration.setIndexedTypes(..) configuration property.
2. Using CacheTypeMetadata configuration class. This one is usually used when it's not an option to change model classes.

Refer to this documentation page for more information on new queries API: http://apacheignite.readme.io/v1.0/docs/cache-queries

-----
This post is migrated from now discontinued Apache Ignite forum at
http://apacheignite.readme.io/v1.0/discuss