Closed xpersonas closed 8 years ago
I'm searching for that to !
You can only search across one entity.
It is an interesting scenario. Do you have an example query?
Example:
I Index all my user, and all m'y project. User are assigned to a project so when i make à request for "User 1" i want to have User 1 from user and all my project where User 1 work on :-)
Actually I'm using two request and merge the result !
This looks a oneToMany/manyToMany relation in your DB. The bundle supports object-relation
Your user entity would look like this:
/**
* @var Project[]
*
* @Solr\Field(type="strings", getter="getName")
*
* @ORM\OneToMany(targetEntity="Project", mappedBy="post", cascade={"persist"})
*/
private $projects;
Yes, my example was wrong !
In my case, i had to mapped three entities :
and i'm using solr for a research field (Incredible no ?) My users can create project, or sample, a sample can be link to a project. If i only use a request on my entity "Project" :
I've got 2 User :
- User1 (Creator of project and admin on my app)
- User2 (Worker)
1 Project :
- ProjectName : "User2 - Project1" ProjectCreateBy : User1
3 Sample : SampleName :
- SampleName : "Sample1" Project : "Project1" CreatedBy : "User2"
- SampleName : "Sample2" Project : "Project1" CreatedBy : "User2"
- SampleName : "Sample3" Project : "NULL" CreatedBy : "User1"
If I made a request with research term "User2" I want to return the user, the project and two sample, actually i've got my user and my sample. Did you see what i meen ?
Sorry for my english ...
My example is just for a general site search. If someone searches for "category" then I want to see a result set containing blog posts, articles, news headlines, pages, or what ever entities that have the "category" in the title or body text.
@xpersonas no that is not possible. You must write a select-query and pass it through the solarium-client.
@Krishn4k you can not search across three entities. In your case you can do something like that:
$result = $this->get('solr.client')->getRepository('YourUserEntity')->findOneBy(array(
'projects' => 'projectname'
));
I'm so new to this I shouldn't be allowed on the internet. But I am confused about how this works. In each of your examples you seem to be querying a specific entity...
createQuery('AcmeDemoBundle:Post');
What if I wanted to search across multiple entities? Is that possible? Am I missing how that is accomplished?