Match

Match( index, [ search_terms ] )
Match( index, [ search_terms ] )
Match( index, [ search_terms ] )
Match( index, [ search_terms ] )
match( index, [ search_terms ] )
match( index, [ search_terms ] )
Match( index, [ search_terms ] )
Match( index, [ search_terms ] )

Description

The Match function finds the "search terms" provided to Match in the requested index. The search_terms must be identical to the terms in the index, including both the value of all terms and number of terms. If the index is configured with no terms, then the search_terms argument should be omitted. If the index is configured with multiple terms, then the "search terms" should be an array of values.

When calling Match through paginate, the results are returned as a Collection of type Page. If no matching element is found an empty collection is returned.

Parameters

Argument Type Definition and Requirements

index

Index Reference

A reference to an index, commonly provided as Index(name).

search_terms

Value or Array of Values

Optional - The terms to locate in the index.

Returns

A SetRef for the Match operation.

Examples

The following query searches the index "spells_by_element" for an exact match to the search term "fire". The query is executed by calling the paginate function which returns results as a set of type page.

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

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

The events view of match contains events for instances as they enter and exit the set over time, based on updates to the instances themselves.

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

fmt.Println(result)
client.query(
  Paginate(
    Match(Index("spells_by_element"), "fire"),
    events = true))
client.query(
  q.paginate(
    q.match(q.index("spells_by_element"), "fire"),
    events=True
  ))
$client.query do
  paginate match(index('spells_by_element'), 'fire'),
           events: true
end
client.query(
    Paginate(
        Match(
            index: Index("spells_by_element"),
            terms: "fire"
        ),
        events: true
    )
)
client.query(
  q.Paginate(
    q.Events(q.Match(q.Index("spells_by_element"), "fire"))))
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{
  "resource": {
    "data": [
      {
        "ts": 1509244539203043,
        "action": "create",
        "resource": { "@ref": "classes/spells/181388642046968320" }
      },
      {
        "ts": 1509244539223511,
        "action": "create",
        "resource": { "@ref": "classes/spells/181388642071085568" }
      }
    ]
  }
}
{
  "data": [
    {
      "ts": 1509244539203043,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642046968320" }
    },
    {
      "ts": 1509244539223511,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642071085568" }
    }
  ]
}
{
  data: [
    {
      ts: 1527008249876598,
      action: "add",
      instance: ref(id = "181388642071085568", class = ref(id = "spells", class = ref(id = "classes")))
    },
    {
      ts: 1527008249889400,
      action: "add",
      instance: ref(id = "181388642046968320", class = ref(id = "spells", class = ref(id = "classes")))
    }
  ]
}
map[data:[
  map[ts:1509244539203043 action:add instance:{181388642046968320 0xc420293a00 <nil>}]
  map[ts:1509244539223511 action:add instance:{181388642071085568 0xc420293cc0 <nil>}]
]]
{
  "data": [
    {
      "ts": 1509244539203043,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642046968320" }
    },
    {
      "ts": 1509244539223511,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642071085568" }
    }
  ]
}
{
  "data": [
    {
      "ts": 1509244539203043,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642046968320" }
    },
    {
      "ts": 1509244539223511,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642071085568" }
    }
  ]
}
{
  "data": [
    {
      "ts": 1509244539203043,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642046968320" }
    },
    {
      "ts": 1509244539223511,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642071085568" }
    }
  ]
}
{
  "data": [
    {
      "ts": 1509244539203043,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642046968320" }
    },
    {
      "ts": 1509244539223511,
      "action": "create",
      "resource": { "@ref": "classes/spells/181388642071085568" }
    }
  ]
}
{ data:
   [ { ts: 1526677776479051,
       action: 'add',
       instance:
        Ref(id=181388642046968320, class=Ref(id=spells, class=Ref(id=classes))) },
     { ts: 1526677776479051,
       action: 'add',
       instance:
        Ref(id=181388642071085568, class=Ref(id=spells, class=Ref(id=classes))) } ] }