Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserting MVA Attrubutes #178

Open
KarelWintersky opened this issue Jun 20, 2019 · 2 comments
Open

Inserting MVA Attrubutes #178

KarelWintersky opened this issue Jun 20, 2019 · 2 comments

Comments

@KarelWintersky
Copy link
Contributor

Add to FAQ / ReadME

class SBSearch { 
...
... somewhere above is init() method

public static function createConnection()
    {
        $conn = new Connection();
        $conn->setParams([
            'host' => self::$sphinx_connection_host,
            'port' => self::$sphinx_connection_port
        ]);

        return (new SphinxQL($conn));
    }

public static function rt_ReplaceIndex(string $index_name, array $updateset)
    {
        if (empty($updateset)) return null;

        return self::createConnection()
            ->replace()
            ->into($index_name)
            ->set($updateset)
            ->execute();
 }
...

I am adding data to my index.

$dataset = [
                'id'            =>  $id,
                'title'         =>  $item['title'],
                'short'         =>  $item['short'],
                'text'          =>  $item['text_bb'],

                'date_added'    =>  date_format( date_create_from_format('Y-m-d H:i:s', $item['cdate']), 'U' ),

                'type'          =>  1,
                'photo'         =>  ((@$item['photo']['file'] != "") ? 1 : 0),
                'author'        =>  $item['author'],

                'districts_all' =>  $item['districts_all'],
            ];

            $status = SBSearch::rt_ReplaceIndex($sphinx_target_index, $dataset);

How to add MVA attribute 'rubrics' and 'districts'?
This fields described as

rt_attr_multi			= rubrics
rt_attr_multi			= districts

Easy:

'rubrics'       =>  array_keys($item['rubrics']),
'districts'     =>  array_keys($item['districts'])

Just send to dataset field ARRAY of values.

@oohnoitz
Copy link
Contributor

Not sure what the ask is. I think adding a single line under https://github.com/FoolCode/SphinxQL-Query-Builder#insert-replace mentioning MVA attribute support would be enough. Would welcome a PR for it.

@KarelWintersky
Copy link
Contributor Author

it is not a PR. but a HINT for someone looking answer for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants