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

Match query on trigram list not working as expected #4494

Closed
ChStark opened this issue Jan 2, 2020 · 0 comments · Fixed by #4545
Closed

Match query on trigram list not working as expected #4494

ChStark opened this issue Jan 2, 2020 · 0 comments · Fixed by #4545
Assignees
Labels
area/querylang Issues related to the query language specification and implementation. kind/bug Something is broken. status/accepted We accept to investigate/work on it.

Comments

@ChStark
Copy link

ChStark commented Jan 2, 2020

What version of Dgraph are you using?

1.1.1

Have you tried reproducing the issue with the latest release?

yes

What is the hardware spec (RAM, OS)?

RAM: 1GB
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic

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

Lets say I have the following schema:

<product.title>: string @index(fulltext, trigram) @lang .
<product.tags>: [string] @index(fulltext, trigram) .

And I have the following data:

_:zelda <product.title> "The Legend of Zelda Links Awakening - Nintendo Switch - Standard Edition" .
_:zelda <product.tags> "zelda" .
_:zelda <product.tags> "links" .
_:zelda <product.tags> "awakening" .
_:zelda <product.tags> "switch" .
_:pokemon <product.title> "Pokemon Sword - Nintendo Switch - Standard Edition" .
_:pokemon <product.tags> "pokemon" .
_:pokemon <product.tags> "sword" .
_:pokemon <product.tags> "switch" .

I got the result of the previous 2 nodes if I query

{
  node(func: match( product.tags , "switch" , 0 ) ) {
    uid
    product.title
    product.tags
  }
}

I got the result of the pokemon title if I query

{
  node(func: match( product.tags , "pokemon" , 0 ) ) {
    uid
    product.title
    product.tags
  }
}

So far so good since both terms are exact

Expected behavior and actual result.

But if I do query (note the term "pokenon" being 1 step away considering levenshtein distance )

{
  node(func: match( product.tags , "pokenon" , 1 ) ) {
    uid
    product.title
    product.tags
  }
}

I got 0 results when the expected result is that I should get the pokemon product node

Note that it works if I query

{
  node(func: match( product.tags , "pokeon" , 1 ) ) {
    uid
    product.title
    product.tags
  }
}
{
  node(func: match( product.tags , "pokemmon" , 1 ) ) {
    uid
    product.title
    product.tags
  }
}

It works when the 1 step is add/remove letter, but not replacement of letter

I hope you can fix this, since this is the only think is keeping me of using this solution instead elasticsearch for a project

@danielmai danielmai added area/querylang Issues related to the query language specification and implementation. kind/bug Something is broken. status/accepted We accept to investigate/work on it. labels Jan 2, 2020
@mangalaman93 mangalaman93 self-assigned this Jan 4, 2020
danielmai added a commit that referenced this issue Jan 14, 2020
Fixes #4494.

We try to be smart about calculating the Levenshtein distance by short-circuiting the calculation based on the max-allowed distance, but that ends up returning incorrect distances.

* Remove max argument from levenshteinDistance.
* Update tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/querylang Issues related to the query language specification and implementation. kind/bug Something is broken. status/accepted We accept to investigate/work on it.
Development

Successfully merging a pull request may close this issue.

3 participants