k-samuel / faceted-search

PHP Faceted search library
MIT License
205 stars 14 forks source link

Save index in db #4

Closed Djagannath closed 3 years ago

Djagannath commented 3 years ago

Can I save index in db and how?

k-samuel commented 3 years ago

You can get index data as an array and transform in into json:

/**
*@var Index $searchIndex
*/
$indexData = $searchIndex->getData();
$indexData = json_encode($indexData); 

Save into your database (insert row)

Insert into myTable (indexDataColumn) Values ({$indexData});
Djagannath commented 3 years ago

You can get index data as an array and transform in into json:

/**
*@var Index $searchIndex
*/
$indexData = $searchIndex->getData();
$indexData = json_encode($indexData); 

Save into your database (insert row)

Insert into myTable (indexDataColumn) Values ({$indexData});

thx