Closed Julien-cpsn closed 2 years ago
I can't show any IP address because it is personnal data, sorry for the inconvenience
To better understand the issue, take a look a the Tokenizer class. It will break down the IP address by dots and you'll get bunch of numbers as tokens, which is not helpful in your case. What you can do is to base64 enocode the address:
public function toSearchableArray()
{
return [
'id' => $this->id,
'ip' => base64_encode($this->ip),
'port' => $this->port
];
}
And while doing a search do FluxIP::search(base64_encode('0.0.0.0'))->get()
Don't forget to reindex after changing the toSearchableArray
method
Another option is writing a custom tokenizer specially for IP addresses
Thanks for your reactivity ! Does work really great for a single model search :)
But now I am unfortunately getting another problem :( The query is getting weird when there is dots in the search string (eg. IP Address obviously)
Since I'm searching on different models with the same search terms it gets kinda ridiculous
The IP Address "0.0.0.0" now finds the FluxIP that are concerned (thanks!) but it also returns some more results from other models that aren't supposed to be here but because of the dots. Any suggestion?
Hello !
I've been using TNTsearch for about a week now and it works great, but i'm having a really big problem. I cannot search on IP Adresses in my database, and they aren't indexed (even in the wordlist). It works with everything else, like the port and all my other models.
I've tried many IP Adreeses, to escape every single character, convert it with ip2long(), remove dots but nothing works...
Here's my table definition :
Here my model definition :
My searching code (pretty basic) :
It returns more than 500 results, but this IP Address only appears 9 times in my database. I have more than 24.000 rows in this table.
Does someone have a solution or a suggestion? It's blocking everything for an important project.
Versions : laravel-scout-tntsearch-driver 12.1 tntsearch 3.0 PHP 7.4 PostGreSQL 13.4