1

I have a search feature that uses Views. There is a search box 'filter' that's just a text box which enables users to input text to search the database. Pretty standard stuff.

I'm curious to know however if there are any rules governing how this search functions?

(Ie. if I enter one word, fine it searches on that term. However if I enter two terms I notice it returns no results, even if I know both terms are in a node and in that exact order!). But if I put two or (more?) words in double quotes " " it seems to return items that have both of those words, although not in that sequence necessarily.

Anyway, I'm just wondering if anyone knows if there is a list of rules governing a Views-based search text? thanks.

Note: my search filter is based off 'search: search terms'.

1 Answer 1

1

The rules controlling exposed text field filters are various SQL operators. To give you a good indication of what's happening, navigate to admin/structure/views/settings and enable Show the SQL query option for the Views UI then preview various views with different operators. As you enter different text, you can see the SQL keywords used to filter the view.

For Search: Search terms filter its based off the core Search index. The search module crawls node content, breaks it into text tokens, weights the score according to your settings (see admin/config/search/settings), and builds an index for terms to content.

In terms of fuzzy search technology Drupal's is pretty basic, but it works most of the time. If you're looking for more robust search options there are more advanced solutions out there (Google CSE, Apache Solr, etc.).

2
  • thanks yet again. That gave me a lot more insight into the results I'm getting. One word adds the line 'search_index.word' = 'typed word' to the SQL. Two lines actually does work now (I updated my search index) and produces the same as above for EACH word with an OR operator between them. Double quotes around multiple words produces 'search_dataset.data' LIKE '%word1 word2%'. So yes, about what you'd expect. Thanks again.
    – Sage
    Apr 23, 2015 at 22:21
  • No problem, always glad to give sage advice ;)
    – Shawn Conn
    Apr 24, 2015 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.