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

Multi word text searches cause error in find_nanopubs_with_text #2

Open
raar1 opened this issue Aug 24, 2020 · 2 comments
Open

Multi word text searches cause error in find_nanopubs_with_text #2

raar1 opened this issue Aug 24, 2020 · 2 comments

Comments

@raar1
Copy link

raar1 commented Aug 24, 2020

Hi Tobias,

It seems that search terms with more than one word are causing find_nanopubs_with_text to error out. For example, if you try typing "homo sapiens" into the text field on Tapas ( http://grlc.nanopubs.lod.labs.vu.nl/tapas/tapas.html?op=/find_nanopubs_with_text ) then you get the following error dump:

Virtuoso 37000 Error XM029: Free-text expression, line 1: syntax error at sapiens


SPARQL query:
define sql:big-data-const 0 #+ summary: Find nanopublications that contain the given text
#+ method: GET
#+ pagination: 1000
#+ endpoint_in_url: False

prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix dct: <http://purl.org/dc/terms/>
prefix luc: <http://www.ontotext.com/owlim/lucene#>   # for GraphDB
#prefix bif: <http://www.openlinksw.com/schemas/bif#>  # for Virtuoso

select ?np ?graphpred ?subj ?pred ?v ?date ?pubkey where {
  graph npa:graph {
    ?np npa:hasHeadGraph ?h .
    ?np npa:creationDay ?__day_iri .
    ?np npa:creationMonth ?__month_iri .
    ?np npa:creationYear ?__year_iri .
    ?np dct:created ?date .
  }
  graph ?h {
    ?np ?__graphpred_iri ?g .
    bind(?__graphpred_iri as ?graphpred)
  }
  graph ?g {
    { ?subj ?pred ?v . ?v luc:npIdx "homo sapiens" . }
    union
    { ?subj ?pred ?v .  ?v <bif:contains> "homo sapiens" . }
  }
  optional {
    graph npa:graph {
      ?np npa:hasValidSignatureForPublicKey ?pubkey .
    }
    # This duplication is a workaround for a Virtuoso bug (otherwise <bif:contains> above overgenerates):
    graph npa:graph {
      ?np npa:hasValidSignatureForPublicKey ?pubkey .
    }
  }
}
 LIMIT 1000 OFFSET 0

However, if you just enter 'homo' then it works as normal. Any way we can fix this query to allow multi-word searches?

@tkuhn
Copy link
Member

tkuhn commented Aug 24, 2020

Multiword searches are supported but you need to use Boolean syntax, i.e. "homo AND sapiens" instead of "homo sapiens". Sorry that this isn't very well documented.

@raar1
Copy link
Author

raar1 commented Aug 24, 2020

Ah, ok I see. I also notice that if you use single quotes (e.g. 'homo sapiens') then it works as a single search term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants