Skip to content

regexp i switch not working #5131

@peter-hartmann

Description

@peter-hartmann

What version of Dgraph are you using?

Built at 2019-12-22T11:05:43.246Z
Commit: a8d7358
Commit Info: a8d7358 Sun Dec 22 13:02:31 2019 +0200 (HEAD -> master, origin/master, origin/HEAD

Have you tried reproducing the issue with the latest release?

What is the hardware spec (RAM, OS)?

dgraph on kubernets on MacOS 20GB RAM for container

Steps to reproduce the issue (command/config used to run Dgraph).

Note: I'm sorry but I'm not able to reproduce the issue with the setup below, but it's similar to what the real DB has. Our real DB is quite large and even after populating the large DB the problem seems to occur only after a doing a couple other queries. I have yet to find a good way to reproduce this on a smaller setup but it's very time consuming - so here is what I got so far:

Setup:

async function seed() {
  {
    console.log("### clean");
    let txn = dgraphClient.newTxn();
    try {
      const op = new dgraph.Operation();
      op.setDropAll(true);
      await dgraphClient.alter(op);
      await txn.commit();
    } finally {
      await txn.discard();
    }
  }
  {
    console.log("### schemas")
    let txn = dgraphClient.newTxn();
    try {
      // https://dgraph.io/docs/query-language/#indexing
      const schema = `
Name: string @index(term, fulltext, trigram) .
Description: string @index(term, fulltext, trigram) .
`;
      const op = new dgraph.Operation();
      op.setSchema(schema);
      await dgraphClient.alter(op);
      await txn.commit();
    } finally {
      await txn.discard();
    }
  }
  {
    console.log("### seed-graph");
    let txn = dgraphClient.newTxn();
    try {
      const mu = new dgraph.Mutation();
      mu.setSetJson([
        { Name: 'Unit' },
        { Name: 'Module' },
        { Name: 'Block' },
      ]);
      const req = new dgraph.Request();
      req.setMutationsList([mu]);
      await txn.doRequest(req);
      await txn.commit();
    }
    catch (e) {
      console.error(e);
      debugger;
    }
    finally {
      await txn.discard();
    }
  }
  console.log('### done');
}

Query

{
  q1(func: regexp(Name, /^Module$/), first: 10) { Name }
  q2(func: regexp(Name, /^[mM][oO][dD]ule$/), first: 10) { Name }
  q3(func: regexp(Name, /^[mM][oO]d[uU]le$/), first: 10) { Name }
  q4(func: regexp(Name, /^[mM][oO][dD][uU]le$/), first: 10) { Name }
  q5(func: regexp(Name, /^module$/i), first: 10) { Name }
}

Response in Console, note: q4 and q5 are empty.

{
  "data": {
    "q1": [
      {
        "Name": "Module"
      }
    ],
    "q2": [
      {
        "Name": "Module"
      }
    ],
    "q3": [
      {
        "Name": "Module"
      }
    ],
    "q4": [],
    "q5": []
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 224800,
      "processing_ns": 7529200,
      "encoding_ns": 32500,
      "assign_timestamp_ns": 1490500,
      "total_ns": 9581100
    },
    "txn": {
      "start_ts": 184670
    },
    "metrics": {
      "num_uids": {
        "Name": 3
      }
    }
  }
}

Expected response

all queries should return the object with Name Module.
It seem only broken a few Names e.g. module broke but searching for area worked fine with the i switch.
Also using more than 3 character groups in the regex seems to cause issues with matching.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/querylang/functionkind/bugSomething is broken.status/acceptedWe accept to investigate/work on it.status/needs-attentionThis issue needs more eyes on it, more investigation might be required before accepting/rejecting it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions