Prev | Current Page 329 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

On the other hand, the results of an
all-words search should contain only the products that contain all of the words you??™re searching
for (???beautiful??? and ???flower,??? in this case). For all-words searches, you need to use the Boolean
mode of the full-text search feature, which allows using AND/OR logic in the search criteria.
The new query would look like this:
SELECT name, description FROM product
WHERE MATCH (name, description) AGAINST ("+beautiful +flower" IN BOOLEAN MODE)
ORDER BY MATCH (name, description) AGAINST ("+beautiful +flower" IN BOOLEAN MODE)
DESC;
Sorting in descending order by the match value isn??™t required but is highly desirable, since
you usually want to receive the search results in descending order by relevance. The leading
CHAPTER 8 ?–  SEARCHING THE CATALOG 229
plus sign marks the required words, so it needs to be added for every word in an all-word search.
Compared to the any-words search, this query returns only seven products, which you can see
in Figure 8-5.
Figure 8-5. Results of an all-words search
MORE FULLTEXT FINE-TUNING: QUERY EXPANSION
The full-text search with query expansion feature was introduced in MySQL 4.1.1 and allows MySQL to find
products that match not only the words searched for but also related words.
When searching with query expansion, MySQL performs the search twice behind the scenes.


Pages:
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
Apartamenty Świnoujście noclegi hel Lokaty jednodniowe projekty domków letniskowych męskie skarpetki rowerowe