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

[FR] Query optional for geo use cases in FT.SEARCH #136

Closed
stockholmux opened this issue Aug 17, 2017 · 6 comments
Closed

[FR] Query optional for geo use cases in FT.SEARCH #136

stockholmux opened this issue Aug 17, 2017 · 6 comments

Comments

@stockholmux
Copy link
Contributor

stockholmux commented Aug 17, 2017

Let's say I have 20 widgets scattered around a field. These widgets have certain characteristics (colour, name, whatev) I want searchable, so I use RediSearch and have a location field. Normally, I want to be able to find these widgets by colour and use this

FT.SEARCH widgets "@colour:blue" GEOFILTER location -113.48 53.56 10 m

But sometimes I don't care about those characteristics and I just want to find all the widgets, so my query argument could be empty but that isn't possible.

I can accomplish this with a dirty hack:
FT.SEARCH widgets "~x" GEOFILTER location -113.48 53.56 10 m (x doesn't appear any any of the data... so everything)

I imagine this is not intended to work. Seems like something along the lines of:
FT.GEOONLYSEARCH widget location -113.48 53.56 10 m
or
FT.SEARCH widgets GEOONLY location -113.48 53.56 10 m
Would be the way to address this use case

(I know that geo:widgets/location is just a zset/geo store, but the members are meaningless).

@dvirsky
Copy link
Contributor

dvirsky commented Aug 19, 2017

It would require designing a syntax to allow the geofilter to get into the query language, like the numeric filters. I'm not so sure about how to express it syntactically.

@dvirsky
Copy link
Contributor

dvirsky commented Aug 20, 2017

Ok, how about this for the syntax of geo queries @stockholmux:

since a numeric query is expressed as @field[{min} {max}] i.e. @price:[250 350] etc.

How about we express radius clauses like this:

@field:[{lon} {lat} {radius} {unit}]

e.g.

@location:[32.0853 34.7818 10 km]
@location:[32.0853 34.7818 10000 m]

So having it as optional will look like:

@business_name:mcdonalds ~@location:[32.0853 34.7818 10 km]

And you can also combine it any other way - in unions, negative clauses, intersection with other geo fields, whatever.

Of course it will usually be abstracted by the client library, but I still want a clear and simple syntax for this.

WDYT?

@stockholmux
Copy link
Contributor Author

I think that makes a lot of sense.

My only question would be if you executed something like this:

FT.SEARCH widgets "@location:[32.0853 34.7818 10 km]" GEOFILTER location -113.48 53.56 10 m

I assume the query syntax would take precedent over the geofilter? It might need a little explanation in documentation since they seem very close in application.

@dvirsky
Copy link
Contributor

dvirsky commented Aug 22, 2017

I will deprecate the keyword once I've put it in the query string I guess, and advise against using the keyword.

@dvirsky
Copy link
Contributor

dvirsky commented Aug 22, 2017

And it's not a question of precedence - they will both apply and you will get the intersection of the two filters. If there is no overlap you will get no results.

@dvirsky
Copy link
Contributor

dvirsky commented Sep 13, 2017

It's been merged into master, syntax is "@location:[32.0853 34.7818 10 km]

@dvirsky dvirsky closed this as completed Sep 13, 2017
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