S
S
Sergey2015-04-09 21:01:52
Sphinx
Sergey, 2015-04-09 21:01:52

Why is yii2-sphinx not finding columns in sphinx index?

There is a code:

use yii\sphinx\Query;

$query = new Query;
    $rows = $query->select('text')
        ->from('posts')
        ->all();

var_dump($rows); die();

Gives an error message:
Database Exception - yii\db\Exception
SQLSTATE[42000]: Syntax error or access violation: 1064 index posts: parse error: unknown identifier 'text' (not an attribute, not a function)
The SQL being executed was: SELECT `text` FROM `posts`
Error Info: Array
(
[0] => 42000
[1] => 1064
[2] => index posts: parse error: unknown identifier 'text' (not an attribute, not a function)
)

But mysql table has a text column.
Here is the sphinx config:
source selposts
{
  type			= mysql
  sql_host		= localhost
  sql_user		= uzerrr
  sql_pass		=  pazzz
  sql_db			= database
  sql_port		= 3306	# optional, default is 3306
  #sql_query		= SELECT id, header, text FROM sel_posts WHERE header != 'NULL'
  sql_query               = SELECT * FROM sel_posts    	
}


index posts
{
  source			= selposts
  path			=  /var/lib/sphinx/selectner/posts
  charset_type		= utf-8
}

And indexer posts data collects successfully.
What is the problem? Why is text an unknown column for yii?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander N++, 2015-04-09
@butteff

1 by hand, then what you want to give in the issue must be specified in source
sql_field_string = text
sql_attr_uint = user_id
sql_attr_json = personal_json
sql_attr_timestamp = created_at
2 Use inheritance

source config_mysite
{
  type			= mysql
  sql_host		= localhost
  sql_user		= root
  sql_pass		= mysql
  sql_db			= new_db
  sql_port		= 3306

  sql_query_pre = SET NAMES utf8
    sql_query_pre = SET CHARACTER SET utf8
}

source mysite_selposts :config_mysite
{
  sql_query = \
SELECT `id`, `text` FROM sel_posts  

    sql_field_string = text
}

The 3 registered words you use need to be wrapped in quotes `text`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question