Question

I have developed a php application using Symfony 2 framework, now I want to implement full text searching in my application, its a business application following acl rules based on users and so on. In my application I create documents, below is bit more details:

  • I create documents in my application using form data and uploading attachments part of the form

  • When I save the document, form data is saved in database table but the attachments are saved on file system ( e.g pdf, .doc, .xls ...), the reference to the file which is stored on the file system is kept in database record.

My functionality for full text is very simple when someone does searching all I need to do is search for data in the tables which I can achieve using SQL search but I also need to search attachments which are associated with documents ( form data). Can someone please suggest what I can use to achieve search capability or if someone has some experience if they can provide some links or sample. Thnx.

Was it helpful?

Solution

I was able to resolve this through following, first created a mapping in config.yml as shown

# Elastica Configuration
fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }
    indexes:
        website:
            client: default
            index_name: docova
            types:
                documents:
                    mappings:
                        Doc_Title: ~
                        Description: ~
                        Attachments:
                           type: "object"
                           properties:
                              File_Name:
                              content:
                                 type: attachment
                    persistence:
                        driver: orm
                        model: Docova\DocovaBundle\Entity\Documents
                        provider: ~
                        listener: ~
                        finder: ~

Then I needed to make a change to one of entity to return attachment as a binary content to elastic search as shown below:

return file_get_contents($this->file_path . DIRECTORY_SEPARATOR . $this->getDocument()->getId() . DIRECTORY_SEPARATOR . md5($this->File_Name), 'r');

This solved it for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top