Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.65 KB

includes.md

File metadata and controls

57 lines (41 loc) · 1.65 KB
layout api-command
language Java
permalink api/java/includes/
command includes
related_commands
intersects
intersects/

Command syntax

{% apibody %} sequence.includes(geometry) → sequence geometry.includes(geometry) → bool {% endapibody %}

Description

Tests whether a geometry object is completely contained within another. When applied to a sequence of geometry objects, includes acts as a filter, returning a sequence of objects from the sequence that include the argument.

Example: Is a point included within a 2000-meter circle?

Object point1 = r.point(-117.220406,32.719464);
Object point2 = r.point(-117.206201,32.725186);

r.circle(point1, 2000).includes(point2).run(conn);

// Result:
true

Example: Which of the locations in a list of parks include a given circle?

import com.rethinkdb.gen.ast.Circle;

Circle circle1 = r.circle(r.array(-117.220406, 32.719464), 10)
                  .optArg("unit", "mi");

r.table("parks").g("area").includes(circle1).run(conn);

{% infobox %} The includes command cannot take advantage of a geospatial secondary index. If you're working with large data sets, consider using an index and getIntersecting before includes to narrow down the initial result set. {% endinfobox %}

Example: Rewrite the previous example with getIntersecting.

Circle circle1 = r.circle(r.array(-117.220406, 32.719464), 10)
                  .optArg("unit", "mi");

r.table("parks").getIntersecting(circle1)
 .optArg("index", "area").g("area")
 .includes(circle1).run(conn);