Jump to content

Different selector operators


LostKobrakai
 Share

Recommended Posts

I've build an address fieldtype based on the eventfieldtype module. Now I wanted to use "*=" or "%=" in a selector and got an error, that these aren't supported by the fieldtype. But I need them to work for a search. What do I have to do to get these operators zu work? The subfields I need are only plain text.

Link to comment
Share on other sites

You could try this solution. Put this to the getMatchQuery function.

if(wire('db')->isOperator($operator)) {
   return parent::getMatchQuery($query, $table, $subfield, $operator, $value);
} else {
   $ft = new DatabaseQuerySelectFulltext($query);
   $ft->match($table, $subfield, $operator, $value);
   return $query;
}
  • Like 3
Link to comment
Share on other sites

Thanks, now at least %= is working, so my search is usable. Using *= gives me this error. 

Fatal error: Exception: SQLSTATE[HY000]: General error: Can't find FULLTEXT index matching the column list

It's sad, that this part is left out in the FieldtypeEvent as it should kinda like a blueprint to custom fieldtypes.

Link to comment
Share on other sites

You have to change keys to FULLTEXT in getDatabaseSchema like this …

I wouldn't mind if I didn't had it that way already. That's why I stumbled with it, because everything seemed like in all those other modules.

		$schema['keys']['data'] = 'FULLTEXT KEY data(data)';
		$schema['keys']['street'] = 'FULLTEXT KEY street(street)';
		$schema['keys']['number'] = 'FULLTEXT KEY number(number)';
		$schema['keys']['postal'] = 'FULLTEXT KEY postal(postal)';
		$schema['keys']['city'] = 'FULLTEXT KEY city(city)';
		$schema['keys']['title'] = 'KEY title(title)';
		$schema['keys']['country'] = 'FULLTEXT KEY country(country)';

Edit: Yeah, somehow my mind must have been empty while I wrote this. "lastname" and "province" missing.

Edit2: Can someone explain, a little further what these keywords actually do in the database? In a quick google search I found, that also the order of columns can play a role for indexes, but I'm not that fluid in database stuff.

  • 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...