I am trying to get a full-text search work with ONGRFilterManagerBundle. Everything is configured and added to the project but as soon as I ran a search on some data I found that the search returns completely irrelevant results.
here is my config:
ongr_elasticsearch:
managers:
default:
index:
hosts:
- "%env(ELASTIC_HOST)%:%env(ELASTIC_PORT)%"
index_name: project_search
mappings:
- SearchBundle
ongr_filter_manager:
managers:
search_list:
filters:
- content
- pagination
repository: es.manager.default.typed_content
filters:
content:
type: match
request_field: text
document_field: content
pagination:
type: pager
request_field: page
document_field: ~
options:
count_per_page: 12
max_pages: 8
and here is my document
namespace SearchBundle\Document;
use ONGR\ElasticsearchBundle\Annotation as ES;
/**
* @ES\Document()
*/
class TypedContent implements DocumentInterface
{
/**
* @ES\Id()
* @var string
*/
private $id;
/**
* @ES\Property(type="text")
* @var string
*/
private $content;
/**
* @ES\Property(type="text")
* @var string
*/
private $type;
/**
* @var mixed
*/
private $dataObject;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id): void
{
$this->id = $id;
}
/**
* @return mixed
*/
public function getContent()
{
return $this->content;
}
/**
* @param mixed $content
*/
public function setContent($content): void
{
$this->content = $content;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type): void
{
$this->type = $type;
}
/**
* @return mixed
*/
public function getDataObject()
{
return $this->dataObject;
}
/**
* @param mixed $dataObject
*/
public function setDataObject($dataObject): void
{
$this->dataObject = $dataObject;
}
}
When I search for example the word olive
I will get a resultset of all my documents, although none of them contain a word that is remotely similar to "olive" and the score is "1" on every result.
Who can spot my mistake?
I know now what the problem is. I am using a Symfony form to submit the search terms. In this case the name of the field is
search[text]
but the Manager is expecting the field to be of nametext
. So naturally the search will simply not take the searchterm into account. I will need to change the form to give the field the nametext
instead ofsearch[text]