We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

There are no search results

I use phalcon/forum to create a local project, locally installed elasticsearch1.7.5. I have run scripts/search-tasks.php, I use mysql, I can not search anything,why? thanks in advanced.



11.6k

1: check apache log, no error -> 2:check php log, no error -> 3: check mysql log.. you will isolate where the error happen and it will be easier to help you

I don't know. Probably there is some problem.



2.6k
edited Jun '16
  • As your guide,I checked all the logs, they have no errors.
  • Using commands in elasticsearch, I can get right results like this
  • curl -XGET 'https://localhost:9200/phosphorum/post/_search?q=11
  • But in my project,I can't
  • code tracing
  • E:\wamp64\www\forum\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Transport.php
  • <?php
    try {
            if (isset($body) === true) {
                $body = $this->serializer->serialize($body);
            }
            var_dump($connection->performRequest());exit;
            $response = $connection->performRequest(
                $method,
                $uri,
                $params,
                $body
            );
    
            $connection->markAlive();
            $this->retryAttempts = 0;
    
            $data = $this->serializer->deserialize($response['text'], $response['info']);
            return array(
                'status' => $response['status'],
                'data'   => $data,
                'info'   => $response['info'],
            );
        }
  • $method = 'GET' $uri = '/phosphorum/post/_search' $params = array()
  • $body = "fields":["id","karma"],"query":{"bool":{"must":[{"term":{"title":"11"}},{"term":{"content":"11"}}]}},"from":0,"size":50}
  • Why $data is empty?
  • Forgive my broken english , thanks in advanced!

1: check apache log, no error -> 2:check php log, no error -> 3: check mysql log.. you will isolate where the error happen and it will be easier to help you



11.6k
Accepted
answer

if apache log doesn't return 404 and the script run well from the cli, I think you have to look how you add elasticsearch class to your phalcon project, do you use universal class loader , composer, include in index.php? are you using namespace in your project?, does php log return such a 'class not found' type error?



2.6k

Thank you very much!

I don't know. Probably there is some problem.



2.6k

Thank you for your serious answer! I check my codes, and in Indexer.php, losing title and content . I insert them into fields array, it's OK! Thank u very much!