Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you must use fulltext to search because of one of the sort results you give: if a search phrase matches exactly with a specific keyphrase. With fulltext search it will be the result with more score.</p> <p>For the second order you give, you have to define some kind of relevance (instead of the relevance of fulltext). When you search some keyphrase mysql does not care if it is the first or last, you have to tell it. if the order of insert keyphases is important you can order results by the relevance of fulltext search AND for ID_keyphrase (assuming ID_keyphrase is autonumeric) or you can add a field to indicate your relevance or you can use the position (but position as a field in database).</p> <p>An example:</p> <pre><code>Keyphrase_table ----------- ID listing_table_id keyphrase relevance </code></pre> <p>with this you can have:</p> <pre><code>1 1 keyphrase2 1 2 1 keyphrase1 2 3 2 keyphrase1 1 </code></pre> <p>the listing with id=1 have 2 keyphrase (keyphrase2 and keyphrase1) and the listing with id=2 have 1 keyphrase (keyphrase1)</p> <p>if you search for "keyphrase1" with fulltext the results will be the record 2 and 3. all 2 results have the same relevance to fulltext because both are the same, but if you add as an order the new field "relevance" in your search (<code>Order by THE_RELEVANCE_OF_FULLTEXT DESC,relevance ASC</code>) the record 3 will be the first always because it meets the requeriments of fulltext and is in results lowest position.</p>
 

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