【问题标题】:Sphinx RT Index and SphinxQL QuerySphinx RT 索引和 SphinxQL 查询
【发布时间】:2012-05-15 07:20:23
【问题描述】:

我们正在我们的架构中部署 RT 索引。但是我们需要一些澄清和部署过程中遇到的一些困难。

在索引中定义的架构:

        index logtable
        {
        type = rt
        path = /usr/local/sphinx20/var/data/logtable
        rt_attr_string = TransactionId
            rt_attr_uint = CustomerId
        rt_attr_timestamp = DateOfTransaction
        rt_attr_string = CustomerFeedback
        rt_field = TransactionType
        }

面临的问题

问题 1: 我们如何在 SPHINXQL 中获取 count() 查询结果。因为它对我们很重要,所以根据客户数量,我们必须将其显示在我们的应用程序中。

下面的例子,

Query - select count(*) from logtable where CustomerId='871';   

在 SphinxQL 中 - 我们没有得到这个结果并得到以下错误。ERROR 1064 (42000): index logtable: invalid schema: Count(*) or @count is queried, but not available in the schema.

问题 2: 我在 conf 中为“TransactionId”字段声明为 STRING 属性,但如果该字段在 where 条件下使用,我无法检索记录。

    Example below, 

    select * from logtable where TransactionId='TRA23454'; 

我收到以下错误, ERROR 1064 (42000): sphinxql: 语法错误,意外 $undefined,在 '"TRA23454"' 附近需要 CONST_INT 或 CONST_FLOAT 或 '-'

如果知道,请帮助我们关闭这些问题。

库马兰

【问题讨论】:

    标签: php open-source full-text-search sphinx


    【解决方案1】:
    select * from logtable where TransactionId='TRA23454';
    

    答案:

    select * from logtable where  MATCH('@TransactionId TRA23454')
    

    【讨论】:

      【解决方案2】:

      在第一个示例中,您需要使用 'show meta;' 而不是 count(*)搜索查询后查询,它将包含 total_count 字段。

      select id from logtable where CustomerId='871';   
      show meta;
      

      在第二个示例中,字符串属性不能用于 WHERE、ORDER 或 GROUP 子句。 实际上您需要将 TransactionId 转换为整数并使用整数属性。使用crc32 mysql函数很简单。

      【讨论】:

      • 其实可以使用字符串属性进行排序和分组。但不是不适用于 where 子句
      • 巴里,所以文档不正确?来自文档:从 1.10-beta 开始,字符串只能用于存储和检索。它们不能参与表达式,不能用于过滤、排序或分组(即在 WHERE、ORDER 或 GROUP 子句中)。
      • 是的。该文档已过时。见sphinxsearch.com/bugs/view.php?id=1138
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多