Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

like support in Etso? #17

Open
kpanic opened this issue Aug 15, 2021 · 6 comments
Open

like support in Etso? #17

kpanic opened this issue Aug 15, 2021 · 6 comments

Comments

@kpanic
Copy link

kpanic commented Aug 15, 2021

Hello! thanks for Etso!

I was wondering if it would make sense to implement https://hexdocs.pm/ecto/Ecto.Query.API.html#like/2 in Etso to have basic search capabilities.

A "trick" for prefix search could be something like

iex(55)> :ets.new(:test, [:named_table])
:test
iex(56)> :ets.insert(:test, {'key1', 'like'})
true
iex(57)> :ets.insert(:test, {'key2', 'like2'})
true
iex(58)> :ets.insert(:test, {'key3', 'will like'})
true
iex(59)> :ets.select(:test, [{{'key1' ++ :_, :_}, [], [:"$_"]}])
[{'key1', 'like'}]
iex(60)> :ets.select(:test, [{{'key2' ++ :_, :_}, [], [:"$_"]}])
[{'key2', 'like2'}]
iex(61)> :ets.select(:test, [{{'key' ++ :_, :_}, [], [:"$_"]}]) 
[{'key2', 'like2'}, {'key1', 'like'}, {'key3', 'will like'}]
iex(62)> :ets.select(:test, [{{:_, 'will' ++ :_}, [], [:"$_"]}])         
[{'key3', 'will like'}]
iex(63)> :ets.select(:test, [{{:_, 'like' ++ :_}, [], [:"$_"]}])
[{'key2', 'like2'}, {'key1', 'like'}]

that would satisfy "a_string%", however for "%like" might be trickier

@evadne
Copy link
Owner

evadne commented Aug 15, 2021

Agreed fully. This is viable.

I do wonder how we could accommodate UPDATE WHERE and DELETE WHERE etc. Currently we do not have support for transactions.

@evadne
Copy link
Owner

evadne commented May 20, 2022

@kpanic
Copy link
Author

kpanic commented Jun 19, 2022

@evadne sorry for super slow reply. I have been busy.
However, I just tried

:ets.select(:test, [{{[:_| 'ey2'], :_}, [], [:"$_"]}]) 
[{'key2', 'like2'}]

And it looks like that we could support:

  • LIKE '%string'
  • LIKE 'string%'
  • LIKE '%string%'

Do you want me to give it a shot in implementing it?

@evadne
Copy link
Owner

evadne commented Jun 19, 2022

@kpanic Fantastic news, please indeed try :)

@evadne
Copy link
Owner

evadne commented Jun 27, 2022

@kpanic Any joy?

@kpanic
Copy link
Author

kpanic commented Jun 27, 2022

@evadne Nope for now.
Please be patient. 🙏🏾 I had a look into etso code and thought about an approach, but still kinda busy and enjoying the heatwave also here 🚒
I might have time this weekend 🙏🏾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants