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

Distance function for aggregation APPLY #1246

Merged
merged 11 commits into from
Aug 27, 2020
Merged

Conversation

ashtul
Copy link
Contributor

@ashtul ashtul commented May 27, 2020

fix #916

@codecov
Copy link

codecov bot commented May 27, 2020

Codecov Report

Merging #1246 into master will decrease coverage by 0.02%.
The diff coverage is 83.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1246      +/-   ##
==========================================
- Coverage   81.74%   81.71%   -0.03%     
==========================================
  Files         143      144       +1     
  Lines       20674    20717      +43     
==========================================
+ Hits        16899    16928      +29     
- Misses       3775     3789      +14     
Impacted Files Coverage Δ
src/aggregate/functions/geo.c 83.33% <83.33%> (ø)
src/aggregate/functions/function.c 95.65% <100.00%> (+0.19%) ⬆️
src/legacy_gc.c 85.10% <0.00%> (-3.83%) ⬇️
src/gc.c 86.55% <0.00%> (-2.53%) ⬇️
src/document.c 73.43% <0.00%> (+1.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b6c4ce...15d49ee. Read the comment docs.


env.expect('ft.aggregate', 'idx', 'hilton',
'LOAD', '1', '@location',
'APPLY', 'distance(@location,-0.15036,51.50566)', 'AS', 'distance',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its better that the function will get an equivalent arguments type and not (string, num, num). So I think something like distance(string, string) is better (we will try to parse both string as geo). This way we can also check the distance between two fields in the document for example..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted it this way but the parser automatically treats ',' as separator and therefore splits the string.
We can have another option that will receive two field names.
I should probably add an option for type (meter, feet...). This will make the pressing annoying (combined with the above options). Any idea how to streamline this?

Copy link
Collaborator

@MeirShpilraien MeirShpilraien May 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean if I write something like this : func("a,b") it gets it as 2 arguments? This is a bug by itself..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in agg/expr/parser.y

arglist(A) ::= . [ARGLIST] { A = RS_NewArgList(NULL); }
arglist(A) ::= expr(B) . [ARGLIST] { A = RS_NewArgList(B); }
arglist(A) ::= arglist(B) COMMA expr(C) . [ARGLIST] { 
    A = RSArgList_Append(B, C);
}

We use it to split args
https://oss.redislabs.com/redisearch/Aggregations/#list_of_string_apply_functions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we decide about this? I do not think we should @gkorland @K-Jo? I do think the api should get 2 strings and not string,num,num

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeirShpilraien what do you mean by two strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the parser splits arguments with , and therefore, an input distance(@field,1.2,-3.4) will be parsed as (string, num, num).
We can decide on another char for splitting between long and lat but it won't be intuitive.

Copy link
Collaborator

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I added a comment about the api. Notice that all the geo files will conflict with the geo out of key space PR. Decide which you want to merge first.

@listaction
Copy link

any update on this?

@ashtul ashtul mentioned this pull request Aug 18, 2020
@ashtul
Copy link
Contributor Author

ashtul commented Aug 19, 2020

related to #1442

@ashtul
Copy link
Contributor Author

ashtul commented Aug 27, 2020

@MeirShpilraien fixed.
Please check docs

Copy link
Collaborator

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big 👍

@ashtul ashtul merged commit e308b7c into master Aug 27, 2020
@ashtul ashtul deleted the apply-distance-for-master branch August 27, 2020 11:39
| geodistance(field,"lon,lat") | Return distance in meters. | `geodistance(@field,"1.2,-3.4")` |
| geodistance(lon,lat,field) | Return distance in meters. | `geodistance(1.2,-3.4,@field)` |
| geodistance("lon,lat",field) | Return distance in meters. | `geodistance("1.2,-3.4",@field)` |
| geodistance("lon,lat","lon,lat")| Return distance in meters. | `geodistance("1.2,-3.4","5.6,-7.8")` |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashtul needs the one with (lon1, lat1, lon2, lat2)

MeirShpilraien pushed a commit that referenced this pull request Aug 30, 2020
* geo files

* Apply distance for geo

* fix per meir review

* docs

Co-authored-by: Guy Korland <gkorland@gmail.com>
ashtul added a commit that referenced this pull request Sep 2, 2020
* Deprecate ft.add, ft.del, ft.drop

* Fix tests

* review fixes

* some more docs fixes

* more docs fixes

* some more fixes

* CircleCI build logs and readies update (#1463)

* Explanation for spellcheck score (#1429)

* [DOC] explain ft.spellcheck scoring

* add assert

* fix assert location

* if instead of assert

* Fix expire during query (#1437)

* Distance function for aggregation APPLY (#1246)

* geo files

* Apply distance for geo

* fix per meir review

* docs

Co-authored-by: Guy Korland <gkorland@gmail.com>

* Search2 docs (#1383)

* Update index.md
* Update Quick_Start.md
* Update Commands.md

Co-authored-by: Ariel Shtul <ashtul@gmail.com>

* fix flaky test

* expanding on HSET

* clear

* extra docs

* temporary

* geo

Co-authored-by: Rafi Einstein <rafi@redislabs.com>
Co-authored-by: Ariel Shtul <ashtul@gmail.com>
Co-authored-by: Guy Korland <gkorland@gmail.com>
@emmanuelkeller emmanuelkeller added this to the 2.0.0 milestone Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a function to APPLY to calculate geo distance
7 participants