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

Add support for geo distance query #8

Closed
siddharthlatest opened this issue Sep 12, 2016 · 9 comments
Closed

Add support for geo distance query #8

siddharthlatest opened this issue Sep 12, 2016 · 9 comments

Comments

@siddharthlatest
Copy link
Member

siddharthlatest commented Sep 12, 2016

Implement support for Geo Distance Query.

Prerequisites

Code Structure

The code structure will resemble the files in this path - https://github.com/appbaseio/mirage/tree/dev/app/build/singlequery/queries.

There should be two files created: geodistance.query.ts and geodistance.query.spec.ts.

Before PR

  • Ensure the logic is impeccable, a test spec is written, no unused variables are present and indentation matches with the rest of the codebase.
@metagrover
Copy link
Contributor

Hey guys, I need some input with this issue.

I am getting query_parsing_exception - "failed to find geo_point field [pin.location]" when I try to run the query. I am able to generate the query of the format:

{
  "query": {
    "bool": {
      "filter": [
        {
          "geo_distance": {
            "distance": "200km",
            "pin.location": {
              "lat": "40",
              "lon": "-70"
            }
          }
        }
      ]
    }
  }
}

I had to list geo_distance under string in queryList (to check whether I'm able to generate the query of the desired format), since ES is not able to detect the Geo Point type.

Can you suggest a solution to this?

@farhan687
Copy link
Contributor

farhan687 commented Oct 12, 2016

What is the datatype of location field? it should be geo_point, otherwise geo query will fail.

@metagrover
Copy link
Contributor

Yeah about that, do you mean:

Specifying @Input() selectedField: geo_point; in the component and adding mappings in ES?

@farhan687
Copy link
Contributor

No no
I am not asking about typescript datatype.
I am asking about es mapping datatype.

Pin.location should have geo_point datatype of es mapping.

You should add
Geo_point: ['geo_distance'] in ananlyzed, non_analyzed of queryList.

Where geo_point is datatype and geo_distance is query name.

@metagrover
Copy link
Contributor

Yes, I've already done that, but it seems ES is not able to determine the type of the field. It is undefined.

@farhan687
Copy link
Contributor

Then you need to pick a new field and add geo_point mapping for that.

@metagrover
Copy link
Contributor

I've tried that, but I think I am missing something. Type of the field is still undefined.

screen shot 2016-10-12 at 6 01 30 pm

How should I add the geo_point mapping for this field (pin)?

@siddharthlatest
Copy link
Member Author

@metagrover ES field type needs to be defined (via mappings), Elasticsearch can't auto-infer it as geo-point. Since mappings are also immutable starting v2.0, you should define it for a new field. https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html

@siddharthlatest
Copy link
Member Author

Merged in f10cae3.

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

No branches or pull requests

3 participants