I have items table of online store, which has fulltext index on item_title, item_description, item_category columns. I would like to write search script, but having problem with deciding in which mode to search (natural language or boolean mode). Let's say user searches for intel core i5 notebooks
. If I set natural language mode in search script user will not be able to search for query intel core i5 notebooks -apple
. Can anybody explain me the difference between natural language mode and boolean mode? Which is more accurate?
Natural Language Full-Text Search vs Boolean Full-Text Search
Natural Language Full-Text Search: It considers all the text in the search keywords as it is naturally with no characters holding special meaning.
For instance, intel core i5 notebooks -apple
IN NATURAL LANGUAGE MODE would return all matches that contain intel
, core
, i5
, notebooks
, and -apple
.
Boolean Full-Text Search: Some characters have a special meaning. Examples are: +
, -
, *
. In your case, intel core i5 notebooks -apple
IN BOOLEAN MODE would return all matches that contain intel
, core
, i5
, and notebooks
. In the matches to be found apple
must not be included. The -
sign has a special meaning and it will not be considered as regular/natural text.
Back to your question: Which is more accurate?
It depends on the results you want to get. If you want apple
to be present in your results then you may use 'IN NATURAL LANGUAGE MODE'.
If you do not want apple
in your results, then use 'IN BOOLEAN MODE'.
© 2022 - 2024 — McMap. All rights reserved.