Closed GBCVisible closed 10 years ago
Hi @GBCVisible, i think your controller is incomplete. You are passing the text you are searching directly to the finder but you are not specifying where to look. I write here what i think you missed
use Elastica\Query\Bool;
use Elastica\Query\Text;
......
$boolQuery = new Bool();
$jobQuery = new Text();
$jobQuery->setFieldQuery('website.Job.Title', $Job);
$boolQuery->addMust($jobQuery);
.....
$Data = $finder->find($boolQuery);
Try it and tell us!
i have the same problem here... i have tested @lonamiaec solution, but it still comes with no result.. somebody please help...
Hi @Hendra-Huang paste your code here and we'll try to help you
My config :
fos_elastica:
clients:
default: { host: localhost, port: 80 }
indexes:
website:
client: default
types:
book:
mappings:
title: { boost: 3 }
persistence:
driver: orm
model: xxxx\xxxBundle\Entity\Book
provider:
query_builder_method: populateElasticSearch
identifier: id
listener:
finder:
My BookRepository :
public function populateElasticSearch()
{
$em = $this->getEntityManager();
return $em->createQueryBuilder()
->select('b')
->from('xxxBundle:Book', 'b')
->orderBy('b.id');
}
My BookController :
public function searchAction()
{
$finder = $this->container->get('fos_elastica.finder.website.book');
$request = $this->container->get('request');
$queryString = $this->getRequest()->query->get('query');
$boolQuery = new Bool();
$bookQuery = new Text();
$bookQuery->setFieldQuery('title', $queryString);
$boolQuery->addMust($bookQuery);
$paginator = $finder->findPaginated($boolQuery);
$paginator->setCurrentPage($request->get('page', 1), false, true );
return $this->render('xxxBundle:Book:search.html.twig', array(
'paginator' => $paginator
)
);
}
Is there anything wrong @lonamiaec ?
Have you seen $queryStrging content and is it ok? After that, have you search this term directly in elasticsearch? If you get the expected results, can you debug $paginator to see its value before return? maybe elasticsearch is returning some kind of error
$queryString contains the words that going to be search.. the $paginator->getNbResults() returns 0... i never tried to search this term directly.. can you show me the way to search this term directly in elasticsearch ?
@Hendra-Huang http://mobz.github.io/elasticsearch-head/ is a plugin to enable elasticsearch access from the browser. There you can create an structured query with your parameters, and see the search result. I hope this can help you!
okay.. it's working now.. i think the problem is the port.. i reinstall elasticsearch and config the port to 9200 and it's working... thx @lonamiaec for your help.. ^.^
Hi,
My problem is the implementation of a search engine job with ElasticaSearch.
I use FOSElasticaBundle 3.0.* with Symfony 2.3.2 My Config :
My Controller :
The command "php app/console fos:elastica:populate" it's OK.
But, don't find results, even one that matches exactly one title in this BDD.
One idea ?
Thanhs