【问题标题】:Python Cassandra Query LIKEPython Cassandra 查询 LIKE
【发布时间】:2017-09-19 10:20:45
【问题描述】:

如何使用 LIKE 查询动态填充数据

我试过这个:

q1 = sesi.execute("SELECT * FROM document WHERE judul LIKE '%s' ", "cluster" )

但我收到以下错误:

Traceback(最近一次调用最后):文件“”,第 1 行,文件“/var/www/app_arsip/flask/local/lib/python2.7/site-packages/cassandra/cluster.py”,行2012,在执行中

return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state).result()

文件“/var/www/app_arsip/flask/local/lib/python2.7/site-packages/cassandra/cluster.py”,第 2049 行,在 execute_async 中

future = self._create_response_future(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state)

文件“/var/www/app_arsip/flask/local/lib/python2.7/site-packages/cassandra/cluster.py”,第 2109 行,在 _create_response_future query_string = bind_params(query_string,参数,self.encoder) 文件“/var/www/app_arsip/flask/local/lib/python2.7/site-packages/cassandra/query.py”,第 826 行,在 bind_params return query % tuple(encoder.cql_encode_all_types(v) for v in params)

TypeError:字符串格式化期间并非所有参数都转换

希望有人能帮助我

谢谢

【问题讨论】:

    标签: python cassandra


    【解决方案1】:

    更改您的查询,删除单引号并将您的参数用[]括起来

    q1 = sesi.execute("SELECT * FROM document WHERE judul LIKE %s", ["%cluster%"] )
    

    【讨论】:

    • 还没生效,不显示结果
    • 你在用这个查询做什么??你在使用 SASIIndex 吗?
    • 我想找到一个包含我输入的单词的标题,并且我在文档表中使用了SASI索引
    • 在 project.document (title) 上创建自定义索引 search_title 使用 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = { 'analyzed' : 'true', 'analyzer_class' : ' org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer', 'case_sensitive' : 'falsse', 'mode' : 'CONTAINS' };
    • 您要搜索 judul 中包含单词 cluster ?? 的文档?
    猜你喜欢
    • 2017-09-19
    • 2015-02-08
    • 2018-08-21
    • 2021-02-20
    • 2010-11-26
    • 1970-01-01
    • 2021-06-23
    • 2017-01-14
    相关资源
    最近更新 更多