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

Struggling with making NewGeoDistanceQuery work #2080

Open
CGenie opened this issue Sep 25, 2024 · 3 comments
Open

Struggling with making NewGeoDistanceQuery work #2080

CGenie opened this issue Sep 25, 2024 · 3 comments

Comments

@CGenie
Copy link

CGenie commented Sep 25, 2024

Hello,

I have this simple code: https://git.sr.ht/~cgenie/bleve-geo-test/tree/master/item/main.go

I basically copied it from issue #1789 and applied the fixes about indexMapping.TypeField = "type". However, the results are still empty for me:

go run .
ERR:  <nil>
searchResult1 ->  No matches
ERR:  <nil>
searchResult2 ->  2 matches, took 58.666µs

What am I doing wrong?

@CGenie
Copy link
Author

CGenie commented Sep 25, 2024

BTW, if my doc has field name Location and the json transforms that to lowercase location should I put field name in index capitalized or lowercase?

@metonymic-smokey
Copy link
Contributor

Hi @CGenie
apologies for the delay responding. Here's what's missing in your code:
indexMapping.DefaultMapping = newMapping.

When using a geopoint field with bleve, the above line is required to avoid indexing the geo points as numeric values in the _all field.
Here's a unit test for reference - https://github.com/blevesearch/bleve/blob/master/search_test.go#L1862.
Not specifying the DefaultMapping for the index results in 0 results, similar to what you've observed in your test.

@CGenie
Copy link
Author

CGenie commented Sep 30, 2024

OK it works, thank you! This is so nice and at the same time extremely fast (I used DuckDB and needed quite some thinking to get the query as performant as bleve).

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