AND logic in search results


#1

Hi,

Looking for advice on how to adjust the way in which Swiftype handles free-text phrases. At the moment the engine is defaulting to OR logic which can often throw up some unwanted results across common phrases.

I was wondering if there was a simple way to have Swiftype display results for all phrases by AND logic first, then by OR? I think Google handles searches in a slightly similar fashion.

I know users can use double quotes to only show AND logic but many users won’t know this option exists.

Thanks

Oli


#2

Hi, Oli!

It’s possible to have your searches search first with an AND based operator if you customize the search request on your server’s side before it is sent to your Swiftype engine.

Some customers use our jQuery client library along with their own custom function(s) as a way to insert an AND operator between each search term typed in by the end user.

For example, if someone types apple pen pineapple into the search box (and you have the search on your site set to insert the AND operator), your custom script could process and send the query as apple AND pen AND pineapple once the search request is submitted.

When the formatted request is received by Swiftype we’ll apply the boolean operators and return the expected results, excluding those partial phrase matches.

Ways we’ve seen folks achieve this within their UX is by having a dropdown that allows the end user to select which operator to use in their search, triggering the preferred processing function. Or, even more simply, instead of writing custom logic you could include some informational text near the search input that informs the user that AND, OR, & “quotation” boolean operators are supported.

If you’d prefer your engine to return only AND based results by default setting (making it so users would need to manually add OR to their request to get partial matches), we can make that adjustment to your engine from our end. Just let us know!


#3

Thanks for the reply. Is it possible for you to set up the engine defaults on your side to display results by AND first then OR? This way users see both results.


#4

Not at present, unfortunately.

It’s a great idea though! I’ll forward it as a feature request to our product team.


#5

Any update on this? would like this feature as well.