Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So after thinking about this for a while, I decided that the relevance ranking has to be done with 1 query within MySQL.</p> <p>This is because:</p> <ul> <li>Relevance between seperate queries can't be compared.</li> <li>It's hard to combine the contents of multiple searches together in meaningful ways.</li> </ul> <p>I have switched to using 1 index table dedicated to search. Entries are inserted, removed, and updates depending on inserts, removals and updates to the real underlying data in the innodb tables (this is all automatic).</p> <p>The table looks like this:</p> <pre><code>search ============== id //id for the entry type //the table the data came from column //column the data came from type_id //id of the row the in the original table content //text </code></pre> <p>There's a full text index on the content column. It is important to realize that not all columns from all tables will be indexed, only things that I deem to be useful in search has been added.</p> <p>Thus, it's just a simple case of running a query to match on <code>content</code>, retrieve what we have and do further processing. To process the final result, a few more queries would be required to ask the parent table for the title of the search result and perhaps some other meta data, but this is a workable solution.</p> <p>I don't think this approach will really scale (updates and inserts will need to update this table as well), but I think it is a pretty good way to provide decent application wide search for smaller deployments of the application.</p> <p>For scalability, use something like elastic search, solr or lucene.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload