Search code examples
phpopen-sourcefull-text-searchsphinx

Sphinx RT Index and SphinxQL Query


We are deploying the RT index in our architecture. But we need some clarification and some difficulties faced during the deployment.

Schema defined in Index:

        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
        }

Faced Problem

Question 1: How we can get the count() query result in SPHINXQL. Because its important for us, based on customer count we have to take it to show in our application.

Example below,

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

In SphinxQL - We didnt get this result and getting the following error.ERROR 1064 (42000): index logtable: invalid schema: Count(*) or @count is queried, but not available in the schema.

Question 2: i declared as a STRING attribute in conf for the field of "TransactionId", but i cant able to retrieve the records if that fields use in where condition.

    Example below, 

    select * from logtable where TransactionId='TRA23454'; 

Following error i am getting, ERROR 1064 (42000): sphinxql: syntax error, unexpected $undefined, expecting CONST_INT or CONST_FLOAT or '-' near '"TRA23454"'

Please help us to close these issues if knows.

Kumaran


Solution

  • select * from logtable where TransactionId='TRA23454';
    

    Answer :

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