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

Expose points_only option through geo_shape field mapper #12893

Merged
merged 1 commit into from Sep 8, 2015

Conversation

nknize
Copy link
Contributor

@nknize nknize commented Aug 14, 2015

This PR adds a points_only option (defaults to false) to the GeoShapeFieldMapper that exposes the pointsOnly optimization in lucene's RecursivePrefixTreeStrategy. This optimization short-circuits DFS traversal when it is known that the field contains points only. To enforce this option the GeoShapeFieldMapper has been updated to throw a MapperParsingException for any Shape that is not of type Point when the option is set to true. Randomized testing is added and docs are updated. ShapeCollection has also been updated to eventually support MultiPoint. Limitations of S4j are currently the only blocker.

closes #12856

@nknize nknize added :Analytics/Geo Indexing, search aggregations of geo points and shapes review v2.1.0 and removed v2.1.0 labels Aug 14, 2015
ensureGreen();

// test exception handling by attempting to insert a random polygon
ShapeBuilder shape = RandomShapeGenerator.createShape(random());
Copy link
Member

Choose a reason for hiding this comment

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

Just so I understand, the random shape could or could not be a ploygon, so if it is a polygon we want to make sure an exception is thrown (and then finish the test), otherwise we want to use it in a query. Correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. The comment should be more clear (and probably moved inside the catch block). RandomShapeGenerator.createShape generates a random GeoJson compliant object, so that could be one of [Point, MultiPoint, Linestring, MultiLinestring, Polygon, Multipolygon, GeometryCollection]. If the geo_shape mapping is defined with points_only : true then anything other than a Point should throw an exception. That's what we're testing here in the catch block.

@dakrone
Copy link
Member

dakrone commented Sep 1, 2015

Left two very minor comments, other than that looks good to me!

… performance on geo_shape indexes designed to store only points. Includes updated documentation and exception handling for ensuring index integrity on points only data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >enhancement v2.0.0-rc1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose points_only option through geo_shape field mapper
3 participants