Jump to content

Advanced Searching


Tom.
 Share

Recommended Posts

Hello,

I'm currently using Google Geocode to get a postcode from the input. Based on that it searches for matching postcodes. As this will only use area code for example S10 from the full postcode S10 3AQ for example.

So I'm using the selector ^=S10 which works great, until I need to search ^=S1 then it will return everything even S17 3AS. Is it possible to search whole words? In the documentation it says it does, however S1 is the start of the word not the whole word when it comes to S17 3AS.

Thanks,

Tom

Link to comment
Share on other sites

I think that this is intended behaviour. The documentation says "contains the exact word or phrase", but does not say they have to be separated from their surroundings by spaces or some other characters. In fact that is the commonly desired behaviour as you would like to find "orange" in "orаnges" most of the time. So i think your ^=S10 selector will still find S101.

Link to comment
Share on other sites

How about ^='S1 '?

This still returns the same results. S10 and so on.

EDIT - Got it ~='S1 '

I think that this is intended behaviour. The documentation says "contains the exact word or phrase", but does not say they have to be separated from their surroundings by spaces or some other characters. In fact that is the commonly desired behaviour as you would like to find "orange" in "orаnges" most of the time. So i think your ^=S10 selector will still find S101.

Thank you for your input, however is there anyway to do this with a selector?

Link to comment
Share on other sites

ProcessWire trims and escapes selector values, so this doesn’t seem possible with pure PW selectors. You may try something like this…

$query = wire('database')->prepare('SELECT pages_id FROM field_postcode WHERE data like concat(:areacode, " %")');
$query->bindValue(':areacode', 'A1', PDO::PARAM_STR);
$pages->executeQuery($query);
		
$results = $query->fetchAll(PDO::FETCH_COLUMN);
		
$pages_matching_ = $pages->getById($results);
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...