dsp-api
dsp-api copied to clipboard
Gravsearch filter match string with spaces
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#"}
}
do I have to split the string and add an AND between words ? la AND révolution AND vaudoise
maybe it is the escape sequence for the quotes: https://www.w3.org/TR/sparql11-query/#grammarEscapes
the error you see is a syntactical problem
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#"
}
}
and without the quotes?
'la révolution vaudoise'
it works but it retrieves results like a OR between words
I will try tomorrow to inspect the sparql query genrated.
'+la +révolution +vaudoise'?
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...
'+la +révolution +vaudoise'?
it works, I think it is like to add an AND
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