public function queryAnswerTrain(Request $request)
    {
        if (null === $optionsSerial = $request->get('options_serial')) {
            $this->app->abort(400, 'Search engine options are missing');
        }

        try {
            $options = SearchEngineOptions::hydrate($this->app, $optionsSerial);
        } catch (\Exception $e) {
            $this->app->abort(400, 'Provided search engine options are not valid');
        }

        $pos = (int) $request->request->get('pos', 0);
        $query = $request->request->get('query', '');

        $record = new \record_preview($this->app, 'RESULT', $pos, '', $this->getSearchEngine(), $query, $options);

        $index = ($pos - 3) < 0 ? 0 : ($pos - 3);
        return $this->app->json([
            'current' => $this->render('prod/preview/result_train.html.twig', [
                'records'  => $record->get_train(),
                'index' => $index,
                'selected' => $pos,
            ])
        ]);
    }
public function queryAnswerTrain(Request $request)
    {
        if (null === $optionsSerial = $request->get('options_serial')) {
            $this->app->abort(400, 'Search engine options are missing');
        }

        try {
            $options = SearchEngineOptions::hydrate($this->app, $optionsSerial);
        } catch (\Exception $e) {
            $this->app->abort(400, 'Provided search engine options are not valid');
        }

        $pos = (int) $request->request->get('pos', 0);
        $query = $request->request->get('query', '');

        $record = new \record_preview($this->app, 'RESULT', $pos, '', $this->getSearchEngine(), $query, $options);

        $index = ($pos - 3) < 0 ? 0 : ($pos - 3);
        return $this->app->json([
            'current' => $this->render('prod/preview/result_train.html.twig', [
                'records'  => $record->get_train(),
                'index' => $index,
                'selected' => $pos,
            ])
        ]);
    }
public function queryAnswerTrain ( Request $ request ) { if ( null === $ optionsSerial = $ request -> get ( 'options_serial' ) ) { $ this -> app -> abort ( 400 , 'Search engine options are missing' ) ; } try { $ options = SearchEngineOptions :: hydrate ( $ this -> app , $ optionsSerial ) ; } catch ( \ Exception $ e ) { $ this -> app -> abort ( 400 , 'Provided search engine options are not valid' ) ; } $ pos = ( int ) $ request -> request -> get ( 'pos' , 0 ) ; $ query = $ request -> request -> get ( 'query' , '' ) ; $ record = new \ record_preview ( $ this -> app , 'RESULT' , $ pos , '' , $ this -> getSearchEngine ( ) , $ query , $ options ) ; $ index = ( $ pos - 3 ) < 0 ? 0 : ( $ pos - 3 ) ; return $ this -> app -> json ( [ 'current' => $ this -> render ( 'prod/preview/result_train.html.twig' , [ 'records' => $ record -> get_train ( ) , 'index' => $ index , 'selected' => $ pos , ] ) ] ) ; }
Get a preview answer train

@param  Request $request
@return Response
Get a preview answer train