Re: [protege-user] Attribute search with 'AND' condition

Michael DeBellis <[email protected]>
Newsgroups gmane.comp.misc.ontology.protege.owl
Message-ID <CALGFikdc9uLBGZ8wBB7uf=bripMgPyqVjbB5_1nPk8TRtaFEug@mail.gmail.com>
I haven't tried using regular expressions in the Search, but if I'm
understanding what you want to do, there may be another way to do it. Just
to restate:

You have two annotation properties hasA and hasB and you want any entity
that contains the string "ABC" in hasA and "XYZ" in hasB. I wrote the
following and tried it on an ontology I'm working on now related to
environmentalism (using strings I thought should have at least one match)
and it worked:

PREFIX owl:  <http://www.w3.org/2002/07/owl#>
PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX :  <https://www.michaeldebellis.com/climate_obstruction/>

SELECT *
WHERE {?e skos:definition ?s1.
               ?e rdfs:label ?s2.
               FILTER(CONTAINS(?s1, "claim") && CONTAINS(?s2, "the"))}

When I ran that in Snap SPARQL it worked:
[image: SPARQLExample.png]

On Thu, Jun 12, 2025 at 5:34 AM Eric Hwang via protege-user <
[email protected]> wrote:

> I am currently using Desktop Protégé v5.6.4 and would like to perform an
> ‘AND’ search on an entity’s annotation. For example, if I have 2
> attributes: “ATTR_A” and “ATTR_B”, I would like to retrieve all instances
> of entities where ATTR_A has value of ABC and ATTR_B has value of XYZ.
>
>
>
> Using the Search dialog, I checked:
> - Regular Expression
>
> - Show all results
>
> - Search in annotation value
>
>
>
> If I use this search string for ATTR_A, I can see a list of results:
>
> (?=ATTR_A.ABC)
>
>
>
> Same for ATTR_B:
>
> (?=ATTR_B.XYZ)
>
>
>
> However, if I try to combine these 2 statements, I am not able to get any
> results. I’ve tried:
>
> (?=ATTR_A.ABC) (?=ATTR_B.XYZ)
>
> (?=ATTR_A.ABC)AND (?=ATTR_B.XYZ)
>
> (?=ATTR_A.ABC) &&(?=ATTR_B.XYZ)
>
>
>
> Am I doing something wrong here? Any help would be greatly appreciated.
>
>
>
> Thanks,
>
> Eric
>
>
>
> [image: Oracle] <http://www.oracle.com/>
> *Eric Y. Hwang, MD*
> Physician Informaticist
> Mobile: 303-325-6585
>
> [email protected]
>
>
>
>
>
>
> _______________________________________________
> protege-user mailing list
> [email protected]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>

_______________________________________________
protege-user mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/protege-user
image001.png (image/png, 2.5 KB) - not displayed
SPARQLExample.png (image/png, 30.7 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.