You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Sidra shah <s....@gmail.com> on 2017/08/31 17:42:04 UTC
Filter query not working
Hello
I used Filter query in Jena which will filter the query using a name in
text area. In my dataset, the name is John Kim but I want if a user enter
even John, it display the result. I use this query but it does not display.
select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname ?name. ?x
rdfs:label ?label .Filter regex(?name ,'John kim') . }
the ?name is plain literal. The query works when I put the exact name in
the text area but not working when I enter first name or last name.
Re: Filter query not working
Posted by Sidra shah <s....@gmail.com>.
Thank you Lorenz and sorry for late response, I was away.
I have just restrict the user input to just one name (first name) and for
time being, it works for me.
Regards
On Fri, Sep 1, 2017 at 10:21 PM, Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:
> The problem is not in your query but in the application logic.
>
> You have to figure out what a user would enter in the text field of the
> UI. Indeed, a user could enter whole sentences, but you have to find a
> trade-off between what your application supports and its implementation
> complexity.
>
> Note, for those textual retrieval, people sometimes prefer to use IR
> engines. Jena of course also supports fulltext search via an extension
> of standard SPARQL [1]. Take this just as a comment, might be out of
> scope for your task. But again, that's your decision – don't make the
> project more complicated than necessary.
>
>
> [1] https://jena.apache.org/documentation/query/text-query.html
>
>
> On 01.09.2017 17:43, Sidra shah wrote:
> > Sorry Rob, if my question bothered.
> >
> > I thought the problem is in my query and that is why I asked here.,
> >
> > Regards
> >
> > On Fri, Sep 1, 2017 at 6:36 PM, Rob Vesse <rv...@dotnetrdf.org> wrote:
> >
> >> Sidra
> >>
> >> As I have said in the past on this list please do not forget you are
> using
> >> a programming language. You are free to implement your application
> however
> >> you see fit, this will involve you writing some code and making some
> design
> >> decisions. This list does not exist to write code for you. We will do
> our
> >> best to answer Jena specific questions and those related to specific
> >> technologies that Jena supports i.e. RDF, SPARQL etc but we are not a
> >> programming helpdesk.
> >>
> >> String manipulation is a basic task and Java contains substantial
> built-in
> >> functionality for this which you can use to achieve what both I and
> Lorenz
> >> have described. If you are struggling to do this then you should direct
> >> your questions to a general programming forum e.g. StackOverflow
> >>
> >> Rob
> >>
> >> On 01/09/2017 16:22, "Sidra shah" <s....@gmail.com> wrote:
> >>
> >> Hello Rob,
> >>
> >> I have a string variable ss for string John kim, so when user enter
> >> name,
> >> it is saved in ss. how can we then use FILTER(REGEX(?name,
> >> “John|kim”, “i”)
> >>
> >> Or, I just use two text boxes for first name and last name and then
> ?
> >>
> >> FILTER(REGEX(?name, “firstname”, “i”) && REGEX(?name, “lastname”,
> “i”))
> >>
> >>
> >> On Fri, Sep 1, 2017 at 6:12 PM, Rob Vesse <rv...@dotnetrdf.org>
> >> wrote:
> >>
> >> > Really it depends on exactly what you want to do
> >> >
> >> > It is entirely possible to create a regular expression that looks
> >> for only
> >> > a partial match, however you will have to implement logic in your
> >> > application to convert the user provided search string into an
> >> appropriate
> >> > regular expression for your use case.
> >> >
> >> > For example if you want any of the search words entered to be
> >> matched you
> >> > might translate into the following:
> >> >
> >> > FILTER(REGEX(?name, “John|kim”, “i”)
> >> >
> >> > Alternatively if you wanted all that search words to be matched
> you
> >> might
> >> > do the following:
> >> >
> >> > FILTER(REGEX(?name, “John”, “i”) && REGEX(?name, “kim”, “i”))
> >> >
> >> > However you have to do some work to decide how you want to
> translate
> >> the
> >> > user search words into an appropriate regular expression.
> >> >
> >> > Rob
> >> >
> >> > On 01/09/2017 16:01, "Sidra shah" <s....@gmail.com> wrote:
> >> >
> >> > I am sorry Lorenz, but I do not understand
> >> >
> >> > How to split the string by white space and then combine? I
> have
> >> no idea
> >> > about it, currently.
> >> >
> >> > Could you please guide?
> >> >
> >> > On Fri, Sep 1, 2017 at 5:30 PM, Lorenz Buehmann <
> >> > buehmann@informatik.uni-leipzig.de> wrote:
> >> >
> >> > > It should be clear that the REGEX "John kim" does not match
> the
> >> > literal
> >> > > "John".
> >> > >
> >> > > Simply split the string by white space and combine this in
> >> your REGEX
> >> > >
> >> > >
> >> > > On 01.09.2017 15:31, Sidra shah wrote:
> >> > > > Hello Lorenz, thank you
> >> > > >
> >> > > > It matches now matches the name when some one enter
> opposite
> >> case
> >> > like
> >> > > > john, John etc.
> >> > > >
> >> > > > But in my owl file, only first name is given i.e John and
> I
> >> want
> >> > if some
> >> > > > one even type John kim, the query matches. The above query
> >> > supposed to
> >> > > work
> >> > > > for it but it does not display the record when full name
> is
> >> typed.
> >> > > >
> >> > > > + "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is
> java
> >> > variable
> >> > > >
> >> > > > The properties in owl are like:
> >> > > >
> >> > > > Publication publishedBy authors
> >> > > > authors authorname someName //not
> >> string
> >> > literal,
> >> > > > plain
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
> >> > > > buehmann@informatik.uni-leipzig.de> wrote:
> >> > > >
> >> > > >> Jena version please.
> >> > > >>
> >> > > >> Show the other query please.
> >> > > >>
> >> > > >> Share some sample data please.
> >> > > >>
> >> > > >> Note, REGEX is case-sensitive, i.e.
> >> > > >>
> >> > > >> FILTER(regex(?name ,'john')) won't match the literal
> "John
> >> kim"
> >> > > >>
> >> > > >>
> >> > > >> As I don't know the data nor your query, I only know that
> >> the
> >> > query
> >> > > >>
> >> > > >> SELECT *
> >> > > >> WHERE
> >> > > >> { ?x mo:publishedBy ?y ;
> >> > > >> mo:authorname ?name ;
> >> > > >> rdfs:label ?label
> >> > > >> FILTER regex(str(?name), "john", "i")
> >> > > >> }
> >> > > >>
> >> > > >> would match "John kim"
> >> > > >>
> >> > > >> On 31.08.2017 19:42, Sidra shah wrote:
> >> > > >>> Hello
> >> > > >>>
> >> > > >>> I used Filter query in Jena which will filter the query
> >> using a
> >> > name in
> >> > > >>> text area. In my dataset, the name is John Kim but I
> want
> >> if a
> >> > user
> >> > > enter
> >> > > >>> even John, it display the result. I use this query but
> it
> >> does
> >> > not
> >> > > >> display.
> >> > > >>> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname
> >> ?name. ?x
> >> > > >>> rdfs:label ?label .Filter regex(?name ,'John kim') . }
> >> > > >>>
> >> > > >>> the ?name is plain literal. The query works when I put
> the
> >> exact
> >> > name
> >> > > in
> >> > > >>> the text area but not working when I enter first name or
> >> last
> >> > name.
> >> > > >>>
> >> > > >>
> >> > >
> >> > >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >>
> >>
> >>
> >>
> >>
>
>
Re: Filter query not working
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
The problem is not in your query but in the application logic.
You have to figure out what a user would enter in the text field of the
UI. Indeed, a user could enter whole sentences, but you have to find a
trade-off between what your application supports and its implementation
complexity.
Note, for those textual retrieval, people sometimes prefer to use IR
engines. Jena of course also supports fulltext search via an extension
of standard SPARQL [1]. Take this just as a comment, might be out of
scope for your task. But again, that's your decision – don't make the
project more complicated than necessary.
[1] https://jena.apache.org/documentation/query/text-query.html
On 01.09.2017 17:43, Sidra shah wrote:
> Sorry Rob, if my question bothered.
>
> I thought the problem is in my query and that is why I asked here.,
>
> Regards
>
> On Fri, Sep 1, 2017 at 6:36 PM, Rob Vesse <rv...@dotnetrdf.org> wrote:
>
>> Sidra
>>
>> As I have said in the past on this list please do not forget you are using
>> a programming language. You are free to implement your application however
>> you see fit, this will involve you writing some code and making some design
>> decisions. This list does not exist to write code for you. We will do our
>> best to answer Jena specific questions and those related to specific
>> technologies that Jena supports i.e. RDF, SPARQL etc but we are not a
>> programming helpdesk.
>>
>> String manipulation is a basic task and Java contains substantial built-in
>> functionality for this which you can use to achieve what both I and Lorenz
>> have described. If you are struggling to do this then you should direct
>> your questions to a general programming forum e.g. StackOverflow
>>
>> Rob
>>
>> On 01/09/2017 16:22, "Sidra shah" <s....@gmail.com> wrote:
>>
>> Hello Rob,
>>
>> I have a string variable ss for string John kim, so when user enter
>> name,
>> it is saved in ss. how can we then use FILTER(REGEX(?name,
>> “John|kim”, “i”)
>>
>> Or, I just use two text boxes for first name and last name and then ?
>>
>> FILTER(REGEX(?name, “firstname”, “i”) && REGEX(?name, “lastname”, “i”))
>>
>>
>> On Fri, Sep 1, 2017 at 6:12 PM, Rob Vesse <rv...@dotnetrdf.org>
>> wrote:
>>
>> > Really it depends on exactly what you want to do
>> >
>> > It is entirely possible to create a regular expression that looks
>> for only
>> > a partial match, however you will have to implement logic in your
>> > application to convert the user provided search string into an
>> appropriate
>> > regular expression for your use case.
>> >
>> > For example if you want any of the search words entered to be
>> matched you
>> > might translate into the following:
>> >
>> > FILTER(REGEX(?name, “John|kim”, “i”)
>> >
>> > Alternatively if you wanted all that search words to be matched you
>> might
>> > do the following:
>> >
>> > FILTER(REGEX(?name, “John”, “i”) && REGEX(?name, “kim”, “i”))
>> >
>> > However you have to do some work to decide how you want to translate
>> the
>> > user search words into an appropriate regular expression.
>> >
>> > Rob
>> >
>> > On 01/09/2017 16:01, "Sidra shah" <s....@gmail.com> wrote:
>> >
>> > I am sorry Lorenz, but I do not understand
>> >
>> > How to split the string by white space and then combine? I have
>> no idea
>> > about it, currently.
>> >
>> > Could you please guide?
>> >
>> > On Fri, Sep 1, 2017 at 5:30 PM, Lorenz Buehmann <
>> > buehmann@informatik.uni-leipzig.de> wrote:
>> >
>> > > It should be clear that the REGEX "John kim" does not match the
>> > literal
>> > > "John".
>> > >
>> > > Simply split the string by white space and combine this in
>> your REGEX
>> > >
>> > >
>> > > On 01.09.2017 15:31, Sidra shah wrote:
>> > > > Hello Lorenz, thank you
>> > > >
>> > > > It matches now matches the name when some one enter opposite
>> case
>> > like
>> > > > john, John etc.
>> > > >
>> > > > But in my owl file, only first name is given i.e John and I
>> want
>> > if some
>> > > > one even type John kim, the query matches. The above query
>> > supposed to
>> > > work
>> > > > for it but it does not display the record when full name is
>> typed.
>> > > >
>> > > > + "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is java
>> > variable
>> > > >
>> > > > The properties in owl are like:
>> > > >
>> > > > Publication publishedBy authors
>> > > > authors authorname someName //not
>> string
>> > literal,
>> > > > plain
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
>> > > > buehmann@informatik.uni-leipzig.de> wrote:
>> > > >
>> > > >> Jena version please.
>> > > >>
>> > > >> Show the other query please.
>> > > >>
>> > > >> Share some sample data please.
>> > > >>
>> > > >> Note, REGEX is case-sensitive, i.e.
>> > > >>
>> > > >> FILTER(regex(?name ,'john')) won't match the literal "John
>> kim"
>> > > >>
>> > > >>
>> > > >> As I don't know the data nor your query, I only know that
>> the
>> > query
>> > > >>
>> > > >> SELECT *
>> > > >> WHERE
>> > > >> { ?x mo:publishedBy ?y ;
>> > > >> mo:authorname ?name ;
>> > > >> rdfs:label ?label
>> > > >> FILTER regex(str(?name), "john", "i")
>> > > >> }
>> > > >>
>> > > >> would match "John kim"
>> > > >>
>> > > >> On 31.08.2017 19:42, Sidra shah wrote:
>> > > >>> Hello
>> > > >>>
>> > > >>> I used Filter query in Jena which will filter the query
>> using a
>> > name in
>> > > >>> text area. In my dataset, the name is John Kim but I want
>> if a
>> > user
>> > > enter
>> > > >>> even John, it display the result. I use this query but it
>> does
>> > not
>> > > >> display.
>> > > >>> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname
>> ?name. ?x
>> > > >>> rdfs:label ?label .Filter regex(?name ,'John kim') . }
>> > > >>>
>> > > >>> the ?name is plain literal. The query works when I put the
>> exact
>> > name
>> > > in
>> > > >>> the text area but not working when I enter first name or
>> last
>> > name.
>> > > >>>
>> > > >>
>> > >
>> > >
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>>
>>
>>
>>
Re: Filter query not working
Posted by Sidra shah <s....@gmail.com>.
Sorry Rob, if my question bothered.
I thought the problem is in my query and that is why I asked here.,
Regards
On Fri, Sep 1, 2017 at 6:36 PM, Rob Vesse <rv...@dotnetrdf.org> wrote:
> Sidra
>
> As I have said in the past on this list please do not forget you are using
> a programming language. You are free to implement your application however
> you see fit, this will involve you writing some code and making some design
> decisions. This list does not exist to write code for you. We will do our
> best to answer Jena specific questions and those related to specific
> technologies that Jena supports i.e. RDF, SPARQL etc but we are not a
> programming helpdesk.
>
> String manipulation is a basic task and Java contains substantial built-in
> functionality for this which you can use to achieve what both I and Lorenz
> have described. If you are struggling to do this then you should direct
> your questions to a general programming forum e.g. StackOverflow
>
> Rob
>
> On 01/09/2017 16:22, "Sidra shah" <s....@gmail.com> wrote:
>
> Hello Rob,
>
> I have a string variable ss for string John kim, so when user enter
> name,
> it is saved in ss. how can we then use FILTER(REGEX(?name,
> “John|kim”, “i”)
>
> Or, I just use two text boxes for first name and last name and then ?
>
> FILTER(REGEX(?name, “firstname”, “i”) && REGEX(?name, “lastname”, “i”))
>
>
> On Fri, Sep 1, 2017 at 6:12 PM, Rob Vesse <rv...@dotnetrdf.org>
> wrote:
>
> > Really it depends on exactly what you want to do
> >
> > It is entirely possible to create a regular expression that looks
> for only
> > a partial match, however you will have to implement logic in your
> > application to convert the user provided search string into an
> appropriate
> > regular expression for your use case.
> >
> > For example if you want any of the search words entered to be
> matched you
> > might translate into the following:
> >
> > FILTER(REGEX(?name, “John|kim”, “i”)
> >
> > Alternatively if you wanted all that search words to be matched you
> might
> > do the following:
> >
> > FILTER(REGEX(?name, “John”, “i”) && REGEX(?name, “kim”, “i”))
> >
> > However you have to do some work to decide how you want to translate
> the
> > user search words into an appropriate regular expression.
> >
> > Rob
> >
> > On 01/09/2017 16:01, "Sidra shah" <s....@gmail.com> wrote:
> >
> > I am sorry Lorenz, but I do not understand
> >
> > How to split the string by white space and then combine? I have
> no idea
> > about it, currently.
> >
> > Could you please guide?
> >
> > On Fri, Sep 1, 2017 at 5:30 PM, Lorenz Buehmann <
> > buehmann@informatik.uni-leipzig.de> wrote:
> >
> > > It should be clear that the REGEX "John kim" does not match the
> > literal
> > > "John".
> > >
> > > Simply split the string by white space and combine this in
> your REGEX
> > >
> > >
> > > On 01.09.2017 15:31, Sidra shah wrote:
> > > > Hello Lorenz, thank you
> > > >
> > > > It matches now matches the name when some one enter opposite
> case
> > like
> > > > john, John etc.
> > > >
> > > > But in my owl file, only first name is given i.e John and I
> want
> > if some
> > > > one even type John kim, the query matches. The above query
> > supposed to
> > > work
> > > > for it but it does not display the record when full name is
> typed.
> > > >
> > > > + "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is java
> > variable
> > > >
> > > > The properties in owl are like:
> > > >
> > > > Publication publishedBy authors
> > > > authors authorname someName //not
> string
> > literal,
> > > > plain
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
> > > > buehmann@informatik.uni-leipzig.de> wrote:
> > > >
> > > >> Jena version please.
> > > >>
> > > >> Show the other query please.
> > > >>
> > > >> Share some sample data please.
> > > >>
> > > >> Note, REGEX is case-sensitive, i.e.
> > > >>
> > > >> FILTER(regex(?name ,'john')) won't match the literal "John
> kim"
> > > >>
> > > >>
> > > >> As I don't know the data nor your query, I only know that
> the
> > query
> > > >>
> > > >> SELECT *
> > > >> WHERE
> > > >> { ?x mo:publishedBy ?y ;
> > > >> mo:authorname ?name ;
> > > >> rdfs:label ?label
> > > >> FILTER regex(str(?name), "john", "i")
> > > >> }
> > > >>
> > > >> would match "John kim"
> > > >>
> > > >> On 31.08.2017 19:42, Sidra shah wrote:
> > > >>> Hello
> > > >>>
> > > >>> I used Filter query in Jena which will filter the query
> using a
> > name in
> > > >>> text area. In my dataset, the name is John Kim but I want
> if a
> > user
> > > enter
> > > >>> even John, it display the result. I use this query but it
> does
> > not
> > > >> display.
> > > >>> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname
> ?name. ?x
> > > >>> rdfs:label ?label .Filter regex(?name ,'John kim') . }
> > > >>>
> > > >>> the ?name is plain literal. The query works when I put the
> exact
> > name
> > > in
> > > >>> the text area but not working when I enter first name or
> last
> > name.
> > > >>>
> > > >>
> > >
> > >
> >
> >
> >
> >
> >
> >
>
>
>
>
>
>
Re: Filter query not working
Posted by Rob Vesse <rv...@dotnetrdf.org>.
Sidra
As I have said in the past on this list please do not forget you are using a programming language. You are free to implement your application however you see fit, this will involve you writing some code and making some design decisions. This list does not exist to write code for you. We will do our best to answer Jena specific questions and those related to specific technologies that Jena supports i.e. RDF, SPARQL etc but we are not a programming helpdesk.
String manipulation is a basic task and Java contains substantial built-in functionality for this which you can use to achieve what both I and Lorenz have described. If you are struggling to do this then you should direct your questions to a general programming forum e.g. StackOverflow
Rob
On 01/09/2017 16:22, "Sidra shah" <s....@gmail.com> wrote:
Hello Rob,
I have a string variable ss for string John kim, so when user enter name,
it is saved in ss. how can we then use FILTER(REGEX(?name, “John|kim”, “i”)
Or, I just use two text boxes for first name and last name and then ?
FILTER(REGEX(?name, “firstname”, “i”) && REGEX(?name, “lastname”, “i”))
On Fri, Sep 1, 2017 at 6:12 PM, Rob Vesse <rv...@dotnetrdf.org> wrote:
> Really it depends on exactly what you want to do
>
> It is entirely possible to create a regular expression that looks for only
> a partial match, however you will have to implement logic in your
> application to convert the user provided search string into an appropriate
> regular expression for your use case.
>
> For example if you want any of the search words entered to be matched you
> might translate into the following:
>
> FILTER(REGEX(?name, “John|kim”, “i”)
>
> Alternatively if you wanted all that search words to be matched you might
> do the following:
>
> FILTER(REGEX(?name, “John”, “i”) && REGEX(?name, “kim”, “i”))
>
> However you have to do some work to decide how you want to translate the
> user search words into an appropriate regular expression.
>
> Rob
>
> On 01/09/2017 16:01, "Sidra shah" <s....@gmail.com> wrote:
>
> I am sorry Lorenz, but I do not understand
>
> How to split the string by white space and then combine? I have no idea
> about it, currently.
>
> Could you please guide?
>
> On Fri, Sep 1, 2017 at 5:30 PM, Lorenz Buehmann <
> buehmann@informatik.uni-leipzig.de> wrote:
>
> > It should be clear that the REGEX "John kim" does not match the
> literal
> > "John".
> >
> > Simply split the string by white space and combine this in your REGEX
> >
> >
> > On 01.09.2017 15:31, Sidra shah wrote:
> > > Hello Lorenz, thank you
> > >
> > > It matches now matches the name when some one enter opposite case
> like
> > > john, John etc.
> > >
> > > But in my owl file, only first name is given i.e John and I want
> if some
> > > one even type John kim, the query matches. The above query
> supposed to
> > work
> > > for it but it does not display the record when full name is typed.
> > >
> > > + "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is java
> variable
> > >
> > > The properties in owl are like:
> > >
> > > Publication publishedBy authors
> > > authors authorname someName //not string
> literal,
> > > plain
> > >
> > >
> > >
> > >
> > >
> > > On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
> > > buehmann@informatik.uni-leipzig.de> wrote:
> > >
> > >> Jena version please.
> > >>
> > >> Show the other query please.
> > >>
> > >> Share some sample data please.
> > >>
> > >> Note, REGEX is case-sensitive, i.e.
> > >>
> > >> FILTER(regex(?name ,'john')) won't match the literal "John kim"
> > >>
> > >>
> > >> As I don't know the data nor your query, I only know that the
> query
> > >>
> > >> SELECT *
> > >> WHERE
> > >> { ?x mo:publishedBy ?y ;
> > >> mo:authorname ?name ;
> > >> rdfs:label ?label
> > >> FILTER regex(str(?name), "john", "i")
> > >> }
> > >>
> > >> would match "John kim"
> > >>
> > >> On 31.08.2017 19:42, Sidra shah wrote:
> > >>> Hello
> > >>>
> > >>> I used Filter query in Jena which will filter the query using a
> name in
> > >>> text area. In my dataset, the name is John Kim but I want if a
> user
> > enter
> > >>> even John, it display the result. I use this query but it does
> not
> > >> display.
> > >>> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname ?name. ?x
> > >>> rdfs:label ?label .Filter regex(?name ,'John kim') . }
> > >>>
> > >>> the ?name is plain literal. The query works when I put the exact
> name
> > in
> > >>> the text area but not working when I enter first name or last
> name.
> > >>>
> > >>
> >
> >
>
>
>
>
>
>
Re: Filter query not working
Posted by Sidra shah <s....@gmail.com>.
Hello Rob,
I have a string variable ss for string John kim, so when user enter name,
it is saved in ss. how can we then use FILTER(REGEX(?name, “John|kim”, “i”)
Or, I just use two text boxes for first name and last name and then ?
FILTER(REGEX(?name, “firstname”, “i”) && REGEX(?name, “lastname”, “i”))
On Fri, Sep 1, 2017 at 6:12 PM, Rob Vesse <rv...@dotnetrdf.org> wrote:
> Really it depends on exactly what you want to do
>
> It is entirely possible to create a regular expression that looks for only
> a partial match, however you will have to implement logic in your
> application to convert the user provided search string into an appropriate
> regular expression for your use case.
>
> For example if you want any of the search words entered to be matched you
> might translate into the following:
>
> FILTER(REGEX(?name, “John|kim”, “i”)
>
> Alternatively if you wanted all that search words to be matched you might
> do the following:
>
> FILTER(REGEX(?name, “John”, “i”) && REGEX(?name, “kim”, “i”))
>
> However you have to do some work to decide how you want to translate the
> user search words into an appropriate regular expression.
>
> Rob
>
> On 01/09/2017 16:01, "Sidra shah" <s....@gmail.com> wrote:
>
> I am sorry Lorenz, but I do not understand
>
> How to split the string by white space and then combine? I have no idea
> about it, currently.
>
> Could you please guide?
>
> On Fri, Sep 1, 2017 at 5:30 PM, Lorenz Buehmann <
> buehmann@informatik.uni-leipzig.de> wrote:
>
> > It should be clear that the REGEX "John kim" does not match the
> literal
> > "John".
> >
> > Simply split the string by white space and combine this in your REGEX
> >
> >
> > On 01.09.2017 15:31, Sidra shah wrote:
> > > Hello Lorenz, thank you
> > >
> > > It matches now matches the name when some one enter opposite case
> like
> > > john, John etc.
> > >
> > > But in my owl file, only first name is given i.e John and I want
> if some
> > > one even type John kim, the query matches. The above query
> supposed to
> > work
> > > for it but it does not display the record when full name is typed.
> > >
> > > + "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is java
> variable
> > >
> > > The properties in owl are like:
> > >
> > > Publication publishedBy authors
> > > authors authorname someName //not string
> literal,
> > > plain
> > >
> > >
> > >
> > >
> > >
> > > On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
> > > buehmann@informatik.uni-leipzig.de> wrote:
> > >
> > >> Jena version please.
> > >>
> > >> Show the other query please.
> > >>
> > >> Share some sample data please.
> > >>
> > >> Note, REGEX is case-sensitive, i.e.
> > >>
> > >> FILTER(regex(?name ,'john')) won't match the literal "John kim"
> > >>
> > >>
> > >> As I don't know the data nor your query, I only know that the
> query
> > >>
> > >> SELECT *
> > >> WHERE
> > >> { ?x mo:publishedBy ?y ;
> > >> mo:authorname ?name ;
> > >> rdfs:label ?label
> > >> FILTER regex(str(?name), "john", "i")
> > >> }
> > >>
> > >> would match "John kim"
> > >>
> > >> On 31.08.2017 19:42, Sidra shah wrote:
> > >>> Hello
> > >>>
> > >>> I used Filter query in Jena which will filter the query using a
> name in
> > >>> text area. In my dataset, the name is John Kim but I want if a
> user
> > enter
> > >>> even John, it display the result. I use this query but it does
> not
> > >> display.
> > >>> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname ?name. ?x
> > >>> rdfs:label ?label .Filter regex(?name ,'John kim') . }
> > >>>
> > >>> the ?name is plain literal. The query works when I put the exact
> name
> > in
> > >>> the text area but not working when I enter first name or last
> name.
> > >>>
> > >>
> >
> >
>
>
>
>
>
>
Re: Filter query not working
Posted by Rob Vesse <rv...@dotnetrdf.org>.
Really it depends on exactly what you want to do
It is entirely possible to create a regular expression that looks for only a partial match, however you will have to implement logic in your application to convert the user provided search string into an appropriate regular expression for your use case.
For example if you want any of the search words entered to be matched you might translate into the following:
FILTER(REGEX(?name, “John|kim”, “i”)
Alternatively if you wanted all that search words to be matched you might do the following:
FILTER(REGEX(?name, “John”, “i”) && REGEX(?name, “kim”, “i”))
However you have to do some work to decide how you want to translate the user search words into an appropriate regular expression.
Rob
On 01/09/2017 16:01, "Sidra shah" <s....@gmail.com> wrote:
I am sorry Lorenz, but I do not understand
How to split the string by white space and then combine? I have no idea
about it, currently.
Could you please guide?
On Fri, Sep 1, 2017 at 5:30 PM, Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:
> It should be clear that the REGEX "John kim" does not match the literal
> "John".
>
> Simply split the string by white space and combine this in your REGEX
>
>
> On 01.09.2017 15:31, Sidra shah wrote:
> > Hello Lorenz, thank you
> >
> > It matches now matches the name when some one enter opposite case like
> > john, John etc.
> >
> > But in my owl file, only first name is given i.e John and I want if some
> > one even type John kim, the query matches. The above query supposed to
> work
> > for it but it does not display the record when full name is typed.
> >
> > + "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is java variable
> >
> > The properties in owl are like:
> >
> > Publication publishedBy authors
> > authors authorname someName //not string literal,
> > plain
> >
> >
> >
> >
> >
> > On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
> > buehmann@informatik.uni-leipzig.de> wrote:
> >
> >> Jena version please.
> >>
> >> Show the other query please.
> >>
> >> Share some sample data please.
> >>
> >> Note, REGEX is case-sensitive, i.e.
> >>
> >> FILTER(regex(?name ,'john')) won't match the literal "John kim"
> >>
> >>
> >> As I don't know the data nor your query, I only know that the query
> >>
> >> SELECT *
> >> WHERE
> >> { ?x mo:publishedBy ?y ;
> >> mo:authorname ?name ;
> >> rdfs:label ?label
> >> FILTER regex(str(?name), "john", "i")
> >> }
> >>
> >> would match "John kim"
> >>
> >> On 31.08.2017 19:42, Sidra shah wrote:
> >>> Hello
> >>>
> >>> I used Filter query in Jena which will filter the query using a name in
> >>> text area. In my dataset, the name is John Kim but I want if a user
> enter
> >>> even John, it display the result. I use this query but it does not
> >> display.
> >>> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname ?name. ?x
> >>> rdfs:label ?label .Filter regex(?name ,'John kim') . }
> >>>
> >>> the ?name is plain literal. The query works when I put the exact name
> in
> >>> the text area but not working when I enter first name or last name.
> >>>
> >>
>
>
Re: Filter query not working
Posted by Sidra shah <s....@gmail.com>.
I am sorry Lorenz, but I do not understand
How to split the string by white space and then combine? I have no idea
about it, currently.
Could you please guide?
On Fri, Sep 1, 2017 at 5:30 PM, Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:
> It should be clear that the REGEX "John kim" does not match the literal
> "John".
>
> Simply split the string by white space and combine this in your REGEX
>
>
> On 01.09.2017 15:31, Sidra shah wrote:
> > Hello Lorenz, thank you
> >
> > It matches now matches the name when some one enter opposite case like
> > john, John etc.
> >
> > But in my owl file, only first name is given i.e John and I want if some
> > one even type John kim, the query matches. The above query supposed to
> work
> > for it but it does not display the record when full name is typed.
> >
> > + "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is java variable
> >
> > The properties in owl are like:
> >
> > Publication publishedBy authors
> > authors authorname someName //not string literal,
> > plain
> >
> >
> >
> >
> >
> > On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
> > buehmann@informatik.uni-leipzig.de> wrote:
> >
> >> Jena version please.
> >>
> >> Show the other query please.
> >>
> >> Share some sample data please.
> >>
> >> Note, REGEX is case-sensitive, i.e.
> >>
> >> FILTER(regex(?name ,'john')) won't match the literal "John kim"
> >>
> >>
> >> As I don't know the data nor your query, I only know that the query
> >>
> >> SELECT *
> >> WHERE
> >> { ?x mo:publishedBy ?y ;
> >> mo:authorname ?name ;
> >> rdfs:label ?label
> >> FILTER regex(str(?name), "john", "i")
> >> }
> >>
> >> would match "John kim"
> >>
> >> On 31.08.2017 19:42, Sidra shah wrote:
> >>> Hello
> >>>
> >>> I used Filter query in Jena which will filter the query using a name in
> >>> text area. In my dataset, the name is John Kim but I want if a user
> enter
> >>> even John, it display the result. I use this query but it does not
> >> display.
> >>> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname ?name. ?x
> >>> rdfs:label ?label .Filter regex(?name ,'John kim') . }
> >>>
> >>> the ?name is plain literal. The query works when I put the exact name
> in
> >>> the text area but not working when I enter first name or last name.
> >>>
> >>
>
>
Re: Filter query not working
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
It should be clear that the REGEX "John kim" does not match the literal
"John".
Simply split the string by white space and combine this in your REGEX
On 01.09.2017 15:31, Sidra shah wrote:
> Hello Lorenz, thank you
>
> It matches now matches the name when some one enter opposite case like
> john, John etc.
>
> But in my owl file, only first name is given i.e John and I want if some
> one even type John kim, the query matches. The above query supposed to work
> for it but it does not display the record when full name is typed.
>
> + "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is java variable
>
> The properties in owl are like:
>
> Publication publishedBy authors
> authors authorname someName //not string literal,
> plain
>
>
>
>
>
> On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
> buehmann@informatik.uni-leipzig.de> wrote:
>
>> Jena version please.
>>
>> Show the other query please.
>>
>> Share some sample data please.
>>
>> Note, REGEX is case-sensitive, i.e.
>>
>> FILTER(regex(?name ,'john')) won't match the literal "John kim"
>>
>>
>> As I don't know the data nor your query, I only know that the query
>>
>> SELECT *
>> WHERE
>> { ?x mo:publishedBy ?y ;
>> mo:authorname ?name ;
>> rdfs:label ?label
>> FILTER regex(str(?name), "john", "i")
>> }
>>
>> would match "John kim"
>>
>> On 31.08.2017 19:42, Sidra shah wrote:
>>> Hello
>>>
>>> I used Filter query in Jena which will filter the query using a name in
>>> text area. In my dataset, the name is John Kim but I want if a user enter
>>> even John, it display the result. I use this query but it does not
>> display.
>>> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname ?name. ?x
>>> rdfs:label ?label .Filter regex(?name ,'John kim') . }
>>>
>>> the ?name is plain literal. The query works when I put the exact name in
>>> the text area but not working when I enter first name or last name.
>>>
>>
Re: Filter query not working
Posted by Sidra shah <s....@gmail.com>.
Hello Lorenz, thank you
It matches now matches the name when some one enter opposite case like
john, John etc.
But in my owl file, only first name is given i.e John and I want if some
one even type John kim, the query matches. The above query supposed to work
for it but it does not display the record when full name is typed.
+ "Filter regex(str(?name),'"+ss+"', 'i') . " // ss is java variable
The properties in owl are like:
Publication publishedBy authors
authors authorname someName //not string literal,
plain
On Fri, Sep 1, 2017 at 9:07 AM, Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:
> Jena version please.
>
> Show the other query please.
>
> Share some sample data please.
>
> Note, REGEX is case-sensitive, i.e.
>
> FILTER(regex(?name ,'john')) won't match the literal "John kim"
>
>
> As I don't know the data nor your query, I only know that the query
>
> SELECT *
> WHERE
> { ?x mo:publishedBy ?y ;
> mo:authorname ?name ;
> rdfs:label ?label
> FILTER regex(str(?name), "john", "i")
> }
>
> would match "John kim"
>
> On 31.08.2017 19:42, Sidra shah wrote:
> > Hello
> >
> > I used Filter query in Jena which will filter the query using a name in
> > text area. In my dataset, the name is John Kim but I want if a user enter
> > even John, it display the result. I use this query but it does not
> display.
> >
> > select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname ?name. ?x
> > rdfs:label ?label .Filter regex(?name ,'John kim') . }
> >
> > the ?name is plain literal. The query works when I put the exact name in
> > the text area but not working when I enter first name or last name.
> >
>
>
Re: Filter query not working
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Jena version please.
Show the other query please.
Share some sample data please.
Note, REGEX is case-sensitive, i.e.
FILTER(regex(?name ,'john')) won't match the literal "John kim"
As I don't know the data nor your query, I only know that the query
SELECT *
WHERE
{ ?x mo:publishedBy ?y ;
mo:authorname ?name ;
rdfs:label ?label
FILTER regex(str(?name), "john", "i")
}
would match "John kim"
On 31.08.2017 19:42, Sidra shah wrote:
> Hello
>
> I used Filter query in Jena which will filter the query using a name in
> text area. In my dataset, the name is John Kim but I want if a user enter
> even John, it display the result. I use this query but it does not display.
>
> select * WHERE { ?x mo:publishedBy ?y.?x mo:authorname ?name. ?x
> rdfs:label ?label .Filter regex(?name ,'John kim') . }
>
> the ?name is plain literal. The query works when I put the exact name in
> the text area but not working when I enter first name or last name.
>