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

Check for undefined/null field is not working #90

Open
wolfgang-s opened this issue Apr 3, 2017 · 4 comments
Open

Check for undefined/null field is not working #90

wolfgang-s opened this issue Apr 3, 2017 · 4 comments

Comments

@wolfgang-s
Copy link

When I try to query:

{filter: {where: {empty_field_name: null}}} there is an exception:

Trace: [parsing_exception] No text specified for text query, with { line=1 & col=64 }
at .../node_modules/loopback-connector-es/lib/esConnector.js:835:12

Line number could be different, since I'm on my on branch.

@pulkitsinghal
Copy link

pulkitsinghal commented Apr 3, 2017

Thanks for the heads up.

Other than fixing it so we are not running into an exception, in terms of expected behavior:

  1. do you as a user expect to match and retrieve all documents where that fieldName is explicitly null?
  2. do you as a user expect to match and retrieve all documents where that fieldName is null, <empty>, or undefined
  3. do you as a user expect to match and retrieve all documents where that fieldName simply doesn't exist?

I realize that some of my questions are silly because of how ES indexing/storage works but still please humor me.

Also I wonder if loopback has smartly defined an explicit behavior for their ORM for such queries so we don't make this up as we do along! cc @bajtos - What do you think?

@bajtos
Copy link
Member

bajtos commented Apr 4, 2017

Also I wonder if loopback has smartly defined an explicit behavior for their ORM for such queries so we don't make this up as we do along! cc @bajtos - What do you think?

My knowledge of juggler and connectors is limited, @strongloop-community/sq-lb-apex are better suited to help you.

@j-craig
Copy link

j-craig commented Nov 12, 2018

Is there any movement on this? It seems to me like pretty necessary functionality to be able to query a database for nulls.

As to your three questions, I don't much experience with ES, so I can't say all the implications here, but I would say "yes" to 1.

As far as 2, I'm not positive what <empty> and undefined mean to you (or ES), but I take <empty> to mean an empty string value whereas undefined means a document that doesn't have the field (as opposed to a null value for the field). My answer here is that I would not treat an empty string as a null. I'm not so sure on undefined; in a way it seems like it would be nice to include them but on the other hand, if there were some other mechanism to query for undefined then it could simply be added as an or condition (just like you could add the empty string to a query).

For question 3, this would not make sense to me since the query would return documents that don't have the field but not return documents where that field is null.

@j-craig
Copy link

j-craig commented Nov 12, 2018

Also, FWIW, a similar query (filter of {"where": {"field": null}}) with a MongoDB datasource returns documents with an explicit null for the given field, but not documents with an empty string for the field or that do not have such a field.

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

4 participants