#cassandra
#кассандра
Вопрос:
Здравствуйте, коллеги-разработчики, я немного застрял с запросами в cassandra, пытаюсь найти в Google, как добавить ограничение / кондиционирование в cassandra, и получил некоторый пример, поэтому я создаю метод, подобный этому, я использую Hector для клиентского API:
IndexedSlicesQuery<String,String,String> indexedSlicesQuery=new IndexedSlicesQuery<String, String, String>(keyspace, serializer, serializer, serializers);
indexedSlicesQuery.addEqualsExpression(columnName, value);
indexedSlicesQuery.setReturnKeysOnly();
indexedSlicesQuery.setColumnFamily(COLUMNFAMILY);
indexedSlicesQuery.setStartKey("");
QueryResult<OrderedRows<String,String,String>> result=indexedSlicesQuery.execute();
return resu<
правильный ли метод?
является ли метод ‘WHERE’ подобным indexedSlicesQuery.addEqualsExpression(columnName, value);
?
любой орган может мне помочь? я все еще пробую это, потому что я получил некоторую ошибку, подобную этой :
1296 [main] INFO me.prettyprint.cassandra.hector.TimingLogger - start[1306744089788] time[158] tag[READ.fail_]
Exception in thread "main" me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:No indexed columns present in index clause with operator EQ)
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:42)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$12.execute(KeyspaceServiceImpl.java:513)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$12.execute(KeyspaceServiceImpl.java:495)
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:101)
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:221)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.operateWithFailover(KeyspaceServiceImpl.java:129)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.getIndexedSlices(KeyspaceServiceImpl.java:517)
at me.prettyprint.cassandra.model.IndexedSlicesQuery$1.doInKeyspace(IndexedSlicesQuery.java:140)
at me.prettyprint.cassandra.model.IndexedSlicesQuery$1.doInKeyspace(IndexedSlicesQuery.java:131)
at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:85)
at me.prettyprint.cassandra.model.IndexedSlicesQuery.execute(IndexedSlicesQuery.java:130)
прошу прощения за мой вопрос новичка и мой плохой английский .. спасибо ..: D
Обновить
Хорошо, после многократного поиска в Google я нашел решения, основанные на этой ссылке, этот метод заключается в создании index_type при создании некоторого семейства столбцов, подобного этому (на основе этой ссылки):
[default@demo] create column family users with comparator=UTF8Type
... and column_metadata=[{column_name: full_name, validation_class: UTF8Type},
... {column_name: state, validation_class: UTF8Type},
... {column_name: birth_date, validation_class: LongType, index_type: KEYS}];
после создания этого семейства индексированных столбцов вы можете запросить llike ordinray sql в cassandra-cli .. и я бы попробовал это в hector .. спасибо за ваше внимание ..: D
Комментарии:
1. можете ли вы кратко показать свой вариант поиска, подобный для cassandra, в разделе ответов. Это может быть полезно для всех.
Ответ №1:
Вам нужно добавить индекс к столбцу, в котором вы хотите выполнить предложение WHERE.
Комментарии:
1. Привет, Зансон, спасибо за твой ответ, я пытался и успешно в cassandra-cli, но я обнаружил проблему в Hector ..: D