kundera icon indicating copy to clipboard operation
kundera copied to clipboard

question

Open publicocean0 opened this issue 7 years ago • 9 comments

Hi , i m using cassandra. Entity A{name:string,surname:string}

How can search a where name=x and surname=y in a huge big data table. I found secondary index. If i set index for name and surname,can i use this indexes also together? (name and surname). In the case i want make a fulltext seach , how can i ?

publicocean0 avatar Sep 07 '17 17:09 publicocean0

@publicocean0

Please refer PersonCassandraLuceneTest for info on querying.

Check the entity PersonLuceneCassandra for info on annotations.

Also, make sure you add the following line in your persistence.xml to use lucene as indexer:

<property name="index.home.dir" value="lucene" />

You can also use elasticsearch as an indexer.

Hope this answers your queries. Let us know if you have more queries.

-Karthik

karthikprasad13 avatar Sep 08 '17 07:09 karthikprasad13

lucene in the application can work just if you have a unique instance working. In my case i could have multiple instances so i thought to use https://github.com/Stratio/cassandra-lucene-index plugin.So i have a good and simple solution not adding additional nodes in the architecture just for the searching feature. I configured kundera with client datastax.

I will add in server lucene plugin so i can use lucene index in cassandra... this index is mirrored in all the nodes so it is always consistent. For this reason i d like add a annotation for adding

@CustomIndex(using="'com.stratio.cassandra.lucene.Index",options=".....")

in the entity like

CREATE CUSTOM INDEX tweets_index ON tweets ()
USING 'com.stratio.cassandra.lucene.Index'
WITH OPTIONS = {
   'refresh_seconds': '1',
   'schema': '{
      fields: {
         id: {type: "integer"},
         user: {type: "string"},
         body: {type: "text", analyzer: "english"},
         time: {type: "date", pattern: "yyyy/MM/dd"},
         place: {type: "geo_point", latitude: "latitude", longitude: "longitude"}
      }
   }'
};

In addition i have to find a way for adding constraint on index unique

publicocean0 avatar Sep 08 '17 10:09 publicocean0

@publicocean0

Can you explain more about your usecase?

We can achieve this indexing through createNativeQuery (Which will execute the CREATE CUSTOM INDEX query on Cassandra client). Since this indexing is one time thing, you can create this manually.

Let us know why you want a client specific annotation.

-Karthik

karthikprasad13 avatar Sep 08 '17 12:09 karthikprasad13

In all my app i always developped autoconsistent executable. All the info for executing it is inside in the code. The reason is the same because JPA permits to autogenerate schema(indexes are part of DDL). Anyway now i have 2 more urgent issues in my app: org.springframework.dao.InvalidDataAccessApiUsageException: Not an entity, {class:class com.itiboss.app.model.Language}; nested exception is java.lang.IllegalArgumentException: Not an entity, {class:class com.itiboss.app.model.Language} that entity is mapped in persistence.xml , added annotations. app created schema in cassandra automatically but then gives this problem. another problem is using datastax driver. com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.0.7:9042 (com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table schema_keyspaces)) version 3.10.1 for deps is there a more updated version of libraries for 3.11 cassadra?

publicocean0 avatar Sep 08 '17 23:09 publicocean0

i m not expert in cassandra but this sounds strange:


cassandra@cqlsh:example> select * from example.LANGUAGE ;
InvalidRequest: Error from server: code=2200 [Invalid query] message="unconfigured table language"
cassandra@cqlsh:example> select * from example."LANGUAGE" ;

 key | code | enabled | name | tcode
-----+------+---------+------+-------

(0 rows)

select table_name from system_schema."tables" and select table_name from system_schema.tables works .... uhmmm what is the logic in this ?

publicocean0 avatar Sep 09 '17 07:09 publicocean0

i found the reason kundera create schema as CREATE TABLE example."LANGUAGE" instead of CREATE TABLE example.LANGUAGE are 2 different tables. Anyway i tried to execute again java ... but it is not the same error. Anyway how to fix comma problem?

publicocean0 avatar Sep 09 '17 08:09 publicocean0

about first bug Not an entity ... it is a problem with classloader.

publicocean0 avatar Sep 09 '17 08:09 publicocean0

@publicocean0

select table_name from system_schema."tables" and select table_name from system_schema.tablesworks .... uhmmm what is the logic in this ?

In Cassandra, you have to specify case sensitive names in quotes. It will consider all names as small case if quotes are not used. So, LANGUAGE will be considered as language.

-Karthik

karthikprasad13 avatar Sep 11 '17 06:09 karthikprasad13

Hi @publicocean0,

Did you check https://github.com/impetus-opensource/Kundera/wiki/Using-Kundera-with-Spring?

-Dev

devender-yadav avatar Sep 11 '17 06:09 devender-yadav