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

STRING-specific comparison operators #314

Open
TheMrguiller opened this issue Jul 8, 2024 · 5 comments
Open

STRING-specific comparison operators #314

TheMrguiller opened this issue Jul 8, 2024 · 5 comments
Labels
community community Effort - Unknown Effort - Unknown enhancement enhancement Frequency - Monthly Frequency - Monthly Reach - Some Reach - Some Severity - S3 Severity - S3

Comments

@TheMrguiller
Copy link

Hi,

I am new to memgraph and i have observe that there is not documentation on how to use string-specific comparison operators. I have tried the following. but with no success:

results = list(
                    match()
                    .node(labels="Organizations", variable="o")
                    .where(item="o.name",operator="CONTAINS",literal=organization["name"])
                    .return_()
                    .execute()
                )

¿Is there any work arounds?

@katarinasupe
Copy link
Contributor

katarinasupe commented Jul 9, 2024

Hi @TheMrguiller and thank you for opening this issue.
contains() is a function in Memgraph, which we use like this in a Cypher query:

contains(string: string, substring: string) -> (boolean)

We didn't implement a wrapper around this for now, so to do that, you should run smth similar to following query as a workaround:

results = list(
                    match()
                    .node(labels="Organizations", variable="o")
                    .add_custom_cypher("WHERE contains(o.name, " +  organization["name"] + ")")
                    .return_()
                    .execute()
                )

Just tweak/escape the quotes in organization name if needed.

I will leave this issue opened because we should implement functions in the query builder.

@katarinasupe katarinasupe added feature feature enhancement enhancement and removed bug bug feature feature labels Jul 9, 2024
@TheMrguiller
Copy link
Author

Hi @katarinasupe ,

Thank you so much for your response. In the case of wanting to add operators like STARTS WITH and ENDS WITH, could we do in the same way?

@katarinasupe
Copy link
Contributor

Yes @TheMrguiller, you do the same for all functions. Here are the string ones - https://memgraph.com/docs/querying/functions#string-functions. For example, STARTS WITH and ENDS WITH are startsWith and endsWith.

What are you working on? Can you tell me more about the use case?

@TheMrguiller
Copy link
Author

Yes, we are conducting a proof of concept for using Memgraph with Langchain, and we have encountered documents with errors in them. For instance, some names of people are not fully specified or company names are missing their original S.A. designation. Since we don't have the exact, error-free strings, we are aiming to minimize duplicates by utilizing the 'contains' and 'startswith' operators.

@katarinasupe
Copy link
Contributor

@TheMrguiller I get it! Sounds like a cool use case. Keep me posted on how the PoC goes, I would love to get your feedback on Memgraph. If you will need more help, feel free to schedule an office hours call and join our Discord server where you can ask various questions about Memgraph.

@katarinasupe katarinasupe added community community Severity - S3 Severity - S3 Effort - Unknown Effort - Unknown Frequency - Monthly Frequency - Monthly Reach - Some Reach - Some labels Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community Effort - Unknown Effort - Unknown enhancement enhancement Frequency - Monthly Frequency - Monthly Reach - Some Reach - Some Severity - S3 Severity - S3
Projects
Development

No branches or pull requests

3 participants