ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leroyJr <mikematne...@gmail.com>
Subject Re: Trouble Enabling Query Indexing
Date Mon, 25 May 2015 14:52:55 GMT
Thanks Abhishek,  I was hoping that would do the case too.  Despite setting
the index types like you suggested, and then creating the cache, I still
get the following error when attempting to query (this is the same error I
received before setting the index types too.)

javax.cache.CacheException: Indexing is disabled for cache: TestCache
  at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.validate(IgniteCacheProxy.java:480)
  at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:428)
  ... 43 elided

Below is the scala code I've used to demonstrate the indexing issue I've
encountered.  Thanks again for the response.

import org.apache.ignite.configuration._
import org.apache.ignite.cache._
import org.apache.ignite._

import scala.collection.JavaConversions._

val ign = Ignition.start("example-ignite.xml")

// Query Annotation Fields
import org.apache.ignite.cache.query._
import org.apache.ignite.cache.query.annotations._

case class Foo(
    @QuerySqlField(index=true)
    id: Int,

    @QuerySqlField(index=true)
    value: Int,

    @QuerySqlField
    name: String
    )

val fooCacheCfg = new CacheConfiguration[Long,Foo]()
fooCacheCfg.setName("TestCache")
fooCacheCfg.setCacheMode(CacheMode.PARTITIONED)
fooCacheCfg.setIndexedTypes(Long.getClass, Foo.getClass)

val fCache = ign.getOrCreateCache[Long, Foo](fooCacheCfg)

fCache.put(123, Foo(id=1, value=1000, name="bob"))

val q1 = fCache.query(new SqlQuery(Foo.getClass.getName, "id > 0")).getAll()


On Mon, May 25, 2015 at 1:14 AM, Abhishek M [via Apache Ignite Users] <
ml-node+s70518n389h14@n6.nabble.com> wrote:

> Hi,
>
> Dont need to set <property name="queryIndexEnabled" value="true"/>. Remove
> it from config.
>
> When you are creating cache. just put the Index type. like as below:
>
> CacheConfiguration<Long, MyClass> cfg = new CacheConfiguration<Long,
> MyClass>();
> cfg.setIndexedTypes(Long.class, MyClass.class);
> cache = ignite.getOrCreateCache(cfg);
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-ignite-users.70518.x6.nabble.com/Trouble-Enabling-Query-Indexing-tp377p389.html
>  To unsubscribe from Trouble Enabling Query Indexing, click here
> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=377&code=bWlrZW1hdG5leWpyQGdtYWlsLmNvbXwzNzd8LTkwOTQ1NTU3>
> .
> NAML
> <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Mike Matney
Verona, WI

"Welcome to the 21st century, where each passing day becomes more like a
Philip K. Dick novel."




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Trouble-Enabling-Query-Indexing-tp377p403.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Mime
View raw message