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 expressions for string #1

Open
niquola opened this issue Jun 4, 2014 · 11 comments
Open

LIKE expressions for string #1

niquola opened this issue Jun 4, 2014 · 11 comments

Comments

@niquola
Copy link

@niquola niquola commented Jun 4, 2014

Hello,
big thx for jsquery!

We need some additional expressions for strings:

"path" LIKE "val%"
"path" ILIKE "%VAL%"
@akorotkov
Copy link
Member

@akorotkov akorotkov commented Jun 4, 2014

Hi,

In your example, "path" is field in json object or it's path with object keys like "key1.key2.key3.value"?

@niquola
Copy link
Author

@niquola niquola commented Jun 4, 2014

I think path with object keys.
Does jsquery distincts them?

Here is real case:

"gender"  (
   "text" ILIKE "mal%" |
   "coding".# (
      "code" ilike "mal%" |
      "display" ilike "mal% 
   )
)

also cool would be:

"gender".* ilike "mal%"
@akorotkov
Copy link
Member

@akorotkov akorotkov commented Jun 4, 2014

In our current semantics of *

"gender".* ilike "mal%"

would be

"gender"  (
      "text" ILIKE "mal%" |
      "coding" .# (
         "code" ilike "mal%" |
         "display" ilike "mal% 
   )
)

In this case LIKE/ILIKE is matching value without key names.

@niquola
Copy link
Author

@niquola niquola commented Jun 4, 2014

That's ok for * semantic :)

How about ILIKE support in jsquery?

We need it for http://www.hl7.org/implement/standards/fhir/search.html - open source implementation of open HealthIT standard.

We can little-bit sponsor & collaborate on jsquery :)

@niquola
Copy link
Author

@niquola niquola commented Jun 4, 2014

I also saw % and $ in grammar - what are meaning of them?

@feodor
Copy link
Contributor

@feodor feodor commented Jun 4, 2014

niquola wrote:

I also saw |%| and |$| in grammar - what are meaning of them?

- any alement of array

% - any key in object

    • any path
      $ - current value, for example:

      a.key ($ > 10 & $ < 20)
      a.# ($ > 10 & $ < 20)


Reply to this email directly or view it on GitHub
#1 (comment).

Teodor Sigaev E-mail: [email protected]
WWW: http://www.sigaev.ru/

@niquola
Copy link
Author

@niquola niquola commented Jun 4, 2014

@feodor thanks for clarification!

@merlinm
Copy link

@merlinm merlinm commented Jul 7, 2014

bump! it would be very nice to have partial string matching, even if it was only left to right.

@feodor
Copy link
Contributor

@feodor feodor commented Jul 7, 2014

We are thinking about that, but we are afraid that gin index support will be impossible. Only vodka index will be able to support it.

7 июля 2014 г. 20:27:07 CEST, Merlin Moncure [email protected] пишет:

bump! it would be very nice to have partial string matching, even if
it was only left to right.


Reply to this email directly or view it on GitHub:
#1 (comment)

Отправлено с Nokia 3210. Извините за краткость, пожалуйста.

@merlinm
Copy link

@merlinm merlinm commented Jul 8, 2014

On Mon, Jul 7, 2014 at 2:02 PM, Teodor Sigaev [email protected] wrote:

7 июля 2014 г. 20:27:07 CEST, Merlin Moncure [email protected] пишет:

bump! it would be very nice to have partial string matching, even if
it was only left to right.

We are thinking about that, but we are afraid that gin index support will be impossible. Only vodka index will be able to support it.

I thought as much. Precise key value searches on jsquery are
unbelievably fast but I'm struggling with a good way to do range
searches (if I could, I would be able to work around the limitations).
I loaded a huge pg_attribute table (> 2 million records) to see how
well it worked. pg_trgm tends to struggle with this type of dataset
(and json generally) because of all the duplicate trigrams. The
following runs in .5 ms which is just incredible IMO:

postgres=# select count(*) from foo where j @@ 'attrelid ($ = 3721083541)';

count

26

Time: 0.564 ms

However, any range search is problematic. It's evaluating first
clause and double checking the returned list

postgres=# select count(*) from foo where j @@ 'attrelid ($ >=
3721083541 & $ <= 3721083541)';

count

26

(1 row)

Time: 496.856 ms

So, I have a couple of questions.

  1. is there any underlying implementation choices that make optimizing
    the above difficult or impossible, or is it on the roadmap. I know
    strings are problematic, but if > and < operations were possible on
    strings somehow and they were fast, that would cover most use cases
    for me.

  2. regarding VODKA index. Is there any implementation of this that I
    can play with?

  3. (this is a bit off topic), but what is the difference between
    path_value and value_path?

Thanks for your quick answers!

merlin

@merlinm
Copy link

@merlinm merlinm commented Jul 15, 2014

queston on path_value vs value_path is answered pretty well on the youtube video here: https://www.youtube.com/watch?v=2dQjfdXxtJw.

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.