Search code examples
phpsymfonyelasticsearchfoselasticabundle

FOSElasticBundle share mapping types together


I have two mapping (User and Tasks) and when I search for tasks, I want to able to get found tasks with user information with it.

user:
    mappings:
        name: ~
        pic: ~

tasks:
    mappings: 
        content: ~
        created: ~
        user:    integer <-- ID is stored 

How can I share types / model across each other, so when I pull found task, it should also pull the user info with it.


Solution

  • Elasticsearch doesn't provide a native way to 'join' doc_types. Some options:

    1. Query for the task and then the user (2 queries)
    2. Save the user data inside the tasks doc_type (1 query)

      tasks: mappings: content: ~ created: ~ user: name: pic: