Intersection

Intersection( set_1, set_2, ... )
Intersection( set_1, set_2, ... )
Intersection( set_1, set_2, ... )
Intersection( set_1, set_2, ... )
intersection( set_1, set_2, ... )
intersection( set_1, set_2, ... )
Intersection( set_1, set_2, ... )
Intersection( set_1, set_2, ... )

Description

The Intersection function returns a SetRef object that contains the elements that appears in every input SetRef.

Parameters

Argument Type Definition and Requirements

set_n

SetRef

One or more SetRef object to be intersected.

Returns

A SetRef object for the intersection operation.

Examples

The query below intersects the SetRef (i.e. set reference) returned by locating the search term "fire" in the index named "spells_by_element" with the SetRef returned by locating the search term "water" in the Index named "spells_by_element". The Paginate function executes the SetRef and returns the results of the Intersect operation in a Collection of type Page.

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{
          "paginate": {
            "intersection": [
              {
                "match": { "index": "spells_by_element" },
                "terms": "fire"
              },
              {
                "match": { "index": "spells_by_element" },
                "terms": "water"
              }
            ]
          }
        }'
client.Query(
  Paginate(
    Intersection(
      Match(Index("spells_by_element"), "fire"),
      Match(Index("spells_by_element"), "water"))));
System.out.println(
   client.query(
     Paginate(
       Intersection(
         Match(Index(Value("spells_by_element")), Value("fire")),
         Match(Index(Value("spells_by_element")), Value("water"))
       )
     )
   ).get());
result, _ := client.Query(
    f.Paginate(
        f.Intersection(
            f.MatchTerm(f.Index("spells_by_element"), "fire"),
            f.MatchTerm(f.Index("spells_by_element"), "water"),
        ),
    ),
)

fmt.Println(result)
client.query(
  Paginate(
    Intersection(
      Match(Index("spells_by_element"), "fire"),
      Match(Index("spells_by_element"), "water"))))
client.query(
  q.paginate(
    q.intersection(
      q.match(q.index("spells_by_element"), "fire"),
      q.match(q.index("spells_by_element"), "water")
    )
  ))
$client.query do
  paginate intersection(match(index('spells_by_element'), 'fire'),
                        match(index('spells_by_element'), 'water'))
end
client.query(
    Paginate(
        Intersection(
            Match(
                index: Index("spells_by_element"),
                terms: "fire"
            ),
            Match(
                index: Index("spells_by_element"),
                terms: "water"
            )
        )
    )
)
client.query(
  q.Paginate(
    q.Intersection(
      q.Match(q.Index("spells_by_element"), "fire"),
      q.Match(q.Index("spells_by_element"), "water"))))
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{
  "resource": {
    "data": [ { "@ref": "classes/spells/181388642071085568" } ]
  }
}
{ "data": [ { "@ref": "classes/spells/181388642071085568" } ] }
{
  data: [
    ref(id = "181388642071085568", class = ref(id = "spells", class = ref(id = "classes")))
  ]
}
map[data:[{181388642071085568 0xc4202920a0 <nil>}]]
{ "data": [ { "@ref": "classes/spells/181388642071085568" } ] }
{ "data": [ { "@ref": "classes/spells/181388642071085568" } ] }
{ "data": [ { "@ref": "classes/spells/181388642071085568" } ] }
{ "data": [ { "@ref": "classes/spells/181388642071085568" } ] }
{ data: [ Ref(id=181388642071085568, class=Ref(id=spells, class=Ref(id=classes))) ] }

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!