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

Gravsearch filter match string with spaces #1562

Open
gfoo opened this issue Dec 17, 2019 · 11 comments
Open

Gravsearch filter match string with spaces #1562

gfoo opened this issue Dec 17, 2019 · 11 comments

Comments

@gfoo
Copy link

gfoo commented Dec 17, 2019

Is there a way to force Lucene (behind the scene) to match a string with spaces?
In my example I try to match a title : la révolution vaudoise to the property bibliographicNoticeHasTitle.

So I tried to escape the double quote to enforce a string with spaces:

?bibliographicNoticeHasTitle knora-api:valueAsString ?bibliographicNoticeHasTitle_Value .
    FILTER knora-api:match(?bibliographicNoticeHasTitle_Value, "\"la révolution vaudoise\"")
}

but I get this error:

{
"knora-api:error":"org.knora.webapi.TriplestoreResponseException: Triplestore responded with HTTP code 400: MALFORMED QUERY: Lexical error at line 15, column 104.  Encountered: \" \" (32), after : \"Les\"",
"@context":
  { "knora-api":"http://api.knora.org/ontology/knora-api/v2#"}
}
@gfoo
Copy link
Author

gfoo commented Dec 17, 2019

do I have to split the string and add an AND between words ? la AND révolution AND vaudoise

@tobiasschweizer
Copy link
Contributor

maybe it is the escape sequence for the quotes: https://www.w3.org/TR/sparql11-query/#grammarEscapes

@tobiasschweizer
Copy link
Contributor

the error you see is a syntactical problem

@gfoo
Copy link
Author

gfoo commented Dec 17, 2019

I tried that: FILTER knora-api:match(?bibliographicNoticeHasTitle_Value, '\"la révolution vaudoise\"') and still have :

{
    "knora-api:error": "org.knora.webapi.TriplestoreResponseException: Triplestore responded with HTTP code 400: MALFORMED QUERY: Lexical error at line 14, column 103.  Encountered: \" \" (32), after : \"la\"",
    "@context": {
        "knora-api": "http://api.knora.org/ontology/knora-api/v2#"
    }
}

@tobiasschweizer
Copy link
Contributor

and without the quotes?

'la révolution vaudoise'

@gfoo
Copy link
Author

gfoo commented Dec 17, 2019

it works but it retrieves results like a OR between words

@gfoo
Copy link
Author

gfoo commented Dec 17, 2019

I will try tomorrow to inspect the sparql query genrated.

@tobiasschweizer
Copy link
Contributor

'+la +révolution +vaudoise'?

@gfoo
Copy link
Author

gfoo commented Dec 17, 2019

From UI interface point of view I should add a check box match all words or match any words to add or not an AND operator between words...

@gfoo
Copy link
Author

gfoo commented Dec 17, 2019

'+la +révolution +vaudoise'?

it works, I think it is like to add an AND

@tobiasschweizer
Copy link
Contributor

yes, see https://lucene.apache.org/core/7_7_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Boolean_operators

What you tried to do first is a phrase search and I believe it lead to a syntactical error bevause of the quotes

@subotic subotic added this to the Backlog milestone Feb 7, 2020
@irinaschubert irinaschubert removed this from the Backlog milestone Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants