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

regexp i switch not working #5131

Closed
peter-hartmann opened this issue Apr 7, 2020 · 1 comment
Closed

regexp i switch not working #5131

peter-hartmann opened this issue Apr 7, 2020 · 1 comment
Labels
area/querylang/function kind/bug Something is broken. status/accepted We accept to investigate/work on it. status/needs-attention This issue needs more eyes on it, more investigation might be required before accepting/rejecting it

Comments

@peter-hartmann
Copy link

peter-hartmann commented Apr 7, 2020

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.

@shekarm shekarm added kind/bug Something is broken. status/needs-attention This issue needs more eyes on it, more investigation might be required before accepting/rejecting it labels Apr 13, 2020
@lgalatin lgalatin added the status/accepted We accept to investigate/work on it. label Apr 15, 2020
@martinmr
Copy link
Contributor

Closing this as a duplicate of #5102. I am still not sure about #4694 but I suspect it's also a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/querylang/function kind/bug Something is broken. status/accepted We accept to investigate/work on it. status/needs-attention This issue needs more eyes on it, more investigation might be required before accepting/rejecting it
Development

No branches or pull requests

5 participants