Reputation: 470
my table structure ;
CREATE TABLE mydb.person (
firstname text,
lastname text,
age int,
birthdate timestamp,
married boolean,
phone text,
PRIMARY KEY (firstname, lastname)
);
and i wanna get all person details have firstname 'abc'. as i'm providing only partition key ,not cluster key.
getting result from cache only when specify both partition and cluster key.
tried sql query also but gives error table not found.
[error pic][1]https://i.sstatic.net/OFem2.png
cache config is as below:
<!-- Persistence settings for 'cache1' -->
<bean id="cache1_persistence_settings" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
<constructor-arg type="org.springframework.core.io.Resource" value="classpath:persistence/primitive/persistence-settings-1.xml" />
</bean>
<!-- Ignite configuration -->
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<list>
<!-- Configuring persistence for "cache1" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1"/>
<property name="readThrough" value="false"/>
<property name="writeThrough" value="true"/>
<property name="writeBehindEnabled" value="true"/>
<property name="writeBehindFlushSize" value="2"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="backups" value="1"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
<property name="dataSourceBean" value="cassandraAdminDataSource" />
<property name="persistenceSettingsBean" value="cache1_persistence_settings"/>
</bean>
</property>
</bean>
</list>
</property>
<property name="clientMode" value="false"/>
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!--
Ignite provides several options for automatic discovery that can be used
instead os static IP based discovery. For information on all options refer
to our documentation: http://apacheignite.readme.io/docs/cluster-config
-->
<!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
<!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>192.168.0.3:47500..47509</value>
</list>
</property>
</bean>
and have used pojo strategy for key and value.
Upvotes: 0
Views: 512
Reputation: 470
i found that is because of index config in cache config file refer this link config index and Failed to execute SQL . its woking just by adding below lines
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="com.manish.igniteexample.PersonKey"/>
<property name="valueType" value="com.manish.igniteexample.Person"/>
<property name="fields">
<map>
<entry key="firstname" value="java.lang.String"/>
<entry key="lastname" value="java.lang.String"/>
<entry key="age" value="java.lang.Integer"/>
<entry key="married" value="java.lang.Boolean"/>
<entry key="birthDate" value="java.util.Date"/>
<entry key="phone" value="java.lang.Integer"/>
</map>
</property>
<property name="indexes">
<list>
<bean class="org.apache.ignite.cache.QueryIndex">
<constructor-arg value="firstname"/>
</bean>
<bean class="org.apache.ignite.cache.QueryIndex">
<constructor-arg value="lastname"/>
</bean>
</list>
</property>
</bean>
</list>
</property>
Upvotes: 0
Reputation: 421
Apache Ignite allows to search in cache by any fields (not mandatory partition and cluster keys). How properly configure SQL in Apache Ignite read there:https://apacheignite.readme.io/docs#queryentity-based-configuration
Upvotes: 1