3.4. Uploaded Files Content Search
Now we need to provide the possibility of file upload for each book publication and to add uploaded files to the
BookPublication browse screen.
Let us customize
BookPublication entity. Firstly we add a new
file attribute which is a many-to-one ASSOCIATION to
FileDescriptor is the descriptor of the uploaded file (not to be confused with
java.io.FileDescriptor) that enables referencing the file from the data model objects.
Save the changes and append the new attribute to the existing
bookPublication.full view. Then, add the
File attribute to the
BookPublication browse and edit screens. To do this, put the cursor to the line containing the attribute and press Alt+Enter. Select Add entity attribute to screens and in the appeared dialog select screens that you want the new attribute to be added.
Generate new DB scripts, update the database and restart the application server. If DB is recreated, full-text search becomes disabled by default. Check the Value checkbox again in JMX Console, reindex all files, process indexing queue, log out and log in back.
As far as we have added the new attribute, the table of publications on
BookPublication browser screen now contains one more column: File. To fill it in, open any line for editing, upload a text file using the new upload field and click OK. By default, CUBA supports
New files appeared in the table. The appearance of the new column can be adjusted.
Open the JMX Console screen, open the
app-core.fts:type=FtsManager JMX bean and invoke sequentially
processQueue() to re-index the existing instances in the database and files according to the new search configuration. All new and changed data will be indexed automatically with a delay depending on the scheduled task interval, i.e. not longer than 30 seconds.
As a result, Full-text search will now output all the entries including external files contents.